sn-ENS neuron integration

several figures for each batch

source("/Shared_win/projects/RNA_normal/analysis.10x.r")

load integrated obj

GEX.seur <- readRDS("../integration_Nb5d/sn10x_WYS.sct_anno.s.rds")
GEX.seur
## An object of class Seurat 
## 47356 features across 19418 samples within 3 assays 
## Active assay: SCT (20434 features, 0 variable features)
##  2 other assays present: RNA, integrated
##  3 dimensional reductions calculated: pca, tsne, umap
ref.seur <- readRDS("../../20230704_10x_SZJ/analysis_ref/GSE149524.P21.integration_Anno.s.rds")
ref.seur
## An object of class Seurat 
## 37583 features across 4419 samples within 3 assays 
## Active assay: SCT (16365 features, 0 variable features)
##  2 other assays present: RNA, integrated
##  3 dimensional reductions calculated: pca, tsne, umap
# define intAnno1/2 colors
color.A1 <- c("#678BB1","#8AB6CE","#3975C1","#669FDF","#4CC1BD",
              "#BF7E6B","#D46B35","#F19258","#FF8080",
              "#BDAE8D","#BD66C4","#C03778",
              "#97BA59","#DFAB16","#2BA956","#9FE727")

color.A2 <- c("#678BB1","#8AB6CE","#3975C1","#669FDF","#4CC1BD",
              "#BF7E6B","#D46B35","#F19258","#FF8080",
              "#BDAE8D","#BD66C4","#C03778",
              "#97BA59","#C4D116", "#DFAB16","#EDE25A", "#2BA956","#9FE727")


# define batch/condition colors
color.cnt <- scales::hue_pal()(4)[c(2,1,4,3)]

color.test1 <- color.cnt[1:2]
color.test2 <- color.cnt[3:4]

## define feature colors
# Cell2020     
material.heat = function(n){
  colorRampPalette(
    c(
      "#283593", # indigo 800
      "#3F51B5", # indigo
      "#2196F3", # blue
      "#00BCD4", # cyan
      "#4CAF50", # green
      "#8BC34A", # light green
      "#CDDC39", # lime
      "#FFEB3B", # yellow
      "#FFC107", # amber
      "#FF9800", # orange
      "#FF5722"  # deep orange
    )
  )(n)
}

# Immunity2019, na gray
colors.Immunity <-c("#191970","#121285","#0C0C9A","#0707B0","#0101C5","#0014CF","#0033D3","#0053D8","#0072DD","#0092E1","#00B2E6",
                  "#00D1EB","#23E8CD","#7AF17B","#D2FA29","#FFEB00","#FFC300","#FF9B00","#FF8400","#FF7800","#FF6B00","#FF5F00","#FF5300",
                  "#FF4700","#F73B00","#EF2E00","#E62300","#DD1700","#D50B00","#CD0000")


# NatNeur2021, sc-neurons
color.ref <- c("#8AB6CE","#678BB1","#3975C1","#4CC1BD",
               "#C03778","#97BA59","#DFAB16","#BF7E6B",
               "#D46B35","#BDAE8D","#BD66C4","#2BA956",
               "#FF8080","#FF8080","#FF8080","#FF0000")
write.table(color.A1, "figures.integration/color.A1.txt", col.names = F, row.names = F, quote = F)
write.table(color.A2, "figures.integration/color.A2.txt", col.names = F, row.names = F, quote = F)

write.table(color.cnt, "figures.integration/color.condition.txt", col.names = F, row.names = F, quote = F)
scales::show_col(color.A1)

scales::show_col(color.A2)

scales::show_col(color.cnt)

cowplot::plot_grid(
DimPlot(GEX.seur, reduction = "umap", group.by = "intAnno1", label = T, label.size = 3.25,repel = F, pt.size = 0.05,
        cols = color.A1),
  DimPlot(GEX.seur, label = F, pt.size = 0.05, repel = F, reduction = 'umap', group.by = "cnt",
        cols = color.cnt) ,
rel_widths = c(4.8,5),
ncol = 2)

cowplot::plot_grid(
DimPlot(GEX.seur, reduction = "umap", group.by = "intAnno2", label = T, label.size = 2.65,repel = F, pt.size = 0.05,
        cols = color.A2),
  DimPlot(GEX.seur, label = F, pt.size = 0.05, repel = F, reduction = 'umap', group.by = "cnt",
        cols = color.cnt) ,
rel_widths = c(4.85,5),
ncol = 2)

DimPlot(ref.seur, reduction = "umap", label = T, group.by = "Anno1", cols = color.ref) +
  DimPlot(ref.seur, reduction = "umap", label = T, group.by = "Anno2")

PBS_INF

test1.seur <- subset(GEX.seur, subset= cnt %in% c("Nb5d.PBS","Nb5d.INF"))
test1.seur
## An object of class Seurat 
## 47356 features across 8232 samples within 3 assays 
## Active assay: SCT (20434 features, 0 variable features)
##  2 other assays present: RNA, integrated
##  3 dimensional reductions calculated: pca, tsne, umap
test1.seur <- ScaleData(test1.seur, features = rownames(test1.seur))
## Centering and scaling data matrix
cowplot::plot_grid(
DimPlot(test1.seur, reduction = "umap", group.by = "intAnno1", label = T, label.size = 3.25,repel = F, pt.size = 0.15,
        cols = color.A1),
  DimPlot(test1.seur, label = F, pt.size = 0.15, repel = F, reduction = 'umap', group.by = "cnt",
        cols = color.test1) ,
rel_widths = c(4.8,5),
ncol = 2)

cowplot::plot_grid(
DimPlot(test1.seur, reduction = "umap", group.by = "intAnno2", label = T, label.size = 2.65,repel = F, pt.size = 0.15,
        cols = color.A2),
  DimPlot(test1.seur, label = F, pt.size = 0.15, repel = F, reduction = 'umap', group.by = "cnt",
        cols = color.test1) ,
rel_widths = c(4.85,5),
ncol = 2)

CTL_CKO

test2.seur <- subset(GEX.seur, subset= cnt %in% c("Nb5d.CTL","Nb5d.CKO"))
test2.seur
## An object of class Seurat 
## 47356 features across 11186 samples within 3 assays 
## Active assay: SCT (20434 features, 0 variable features)
##  2 other assays present: RNA, integrated
##  3 dimensional reductions calculated: pca, tsne, umap
test2.seur <- ScaleData(test2.seur, features = rownames(test2.seur))
## Centering and scaling data matrix
cowplot::plot_grid(
DimPlot(test2.seur, reduction = "umap", group.by = "intAnno1", label = T, label.size = 3.25,repel = F, pt.size = 0.15,
        cols = color.A1),
  DimPlot(test2.seur, label = F, pt.size = 0.15, repel = F, reduction = 'umap', group.by = "cnt",
        cols = color.test2) ,
rel_widths = c(4.8,5),
ncol = 2)

cowplot::plot_grid(
DimPlot(test2.seur, reduction = "umap", group.by = "intAnno2", label = T, label.size = 2.65,repel = F, pt.size = 0.15,
        cols = color.A2),
  DimPlot(test2.seur, label = F, pt.size = 0.15, repel = F, reduction = 'umap', group.by = "cnt",
        cols = color.test2) ,
rel_widths = c(4.85,5),
ncol = 2)

composition

(processed in s1)

final markers

long

(pass)

short_old

markers.old.s <- list(EMN=c("Chat","Bnc2",#"Tox","Ptprt",
                       "Gfra2","Oprk1",#"Adamtsl1", 
                       "Fbxw15","Fbxw24",#"Chrna7",
                       "Satb1","Cntnap5b",
                       "Gabrb1","Nxph1","Lama2","Lrrc7",
                       "Ryr3",#"Eda",
                       "Tac1",
                       #"Kctd8","Ntrk2",
                       "Penk",
                       "Fut9","Nfatc1","Egfr",#"Mgll",
                       "Chrm3"
                       ),
                 IMN=c("Nos1","Kcnab1",
                       "Gfra1","Etv1",
                       #"Man1a","Airn",
                       "Adcy2","Cmah","Creb5","Vip","Pde1a",
                       "Ebf1"#,"Gpc5"
                       ),
                 IN=c("Npas3","Synpr","St18","Gal",
                      "Neurod6",
                      #"Kcnk13",
                      "Moxd1","Sctr",
                      "Piezo1","Sst",#"Adamts9",
                      "Kcnn2"),
                 IPAN=c("Calb2","Calcb","Nmu","Adgrg6",#"Pcdh10",
                        "Ngfr","Galr1","Il7",#"Aff2",
                        #"Gpr149",
                        "Cdh6","Cdh8",
                        "Clstn2",#"Ano2","Ntrk3",
                        "Cpne4",#"Vwc2l",
                        "Cdh9","Scgn",
                        #"Vcan",
                        "Cck","Piezo2","Kcnh7",
                        #"Rerg",
                        "Bmpr1b","Skap1","Ntng1",
                        "Tafa2","Nxph2"))
pn.intAnno1.test0a <- DotPlot(GEX.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="All intAnno1")
pn.intAnno1.test0a

pn.intAnno2.test0a <- DotPlot(GEX.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="All intAnno2")
pn.intAnno2.test0a

pn.intAnno1.test0b <- DotPlot(GEX.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="All intAnno1")
pn.intAnno1.test0b

pn.intAnno2.test0b <- DotPlot(GEX.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="All intAnno2")
pn.intAnno2.test0b

pn.intAnno1.test1a <- DotPlot(test1.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno1")
pn.intAnno1.test1a

pn.intAnno2.test1a <- DotPlot(test1.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno2")
pn.intAnno2.test1a

pn.intAnno1.test1b <- DotPlot(test1.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno1")
pn.intAnno1.test1b

pn.intAnno2.test1b <- DotPlot(test1.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno2")
pn.intAnno2.test1b

pn.intAnno1.test2a <- DotPlot(test2.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno1")
pn.intAnno1.test2a

pn.intAnno2.test2a <- DotPlot(test2.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno2")
pn.intAnno2.test2a

pn.intAnno1.test2b <- DotPlot(test2.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno1")
pn.intAnno1.test2b

pn.intAnno2.test2b <- DotPlot(test2.seur, features = as.vector(unlist(markers.old.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno2")
pn.intAnno2.test2b

pn.ref.a <- DotPlot(ref.seur, features = as.vector(unlist(markers.old.s)), group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="NatNeur2021 P21")
pn.ref.a

pn.ref.b <- DotPlot(ref.seur, features = as.vector(unlist(markers.old.s)), group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="NatNeur2021 P21")
pn.ref.b

short_new

markers.new.s <- list(EMN=c("Chat","Bnc2",#"Tox","Ptprt",
                       "Gfra2","Oprk1",#"Adamtsl1", 
                       "Fbxw15","Fbxw24",#"Chrna7",
                       "Satb1","Itga6","Cntnap5b",
                       "Chgb","Nxph1",
                       "Lama2","Efnb2","Itgb8",
                       "Lrrc7",
                       "Ryr3",#"Eda",
                       "Tac1",
                       #"Kctd8","Ntrk2",
                       "Penk",
                       "Fut9","Nfatc1","Egfr",#"Mgll",
                       "Chrm3"
                       ),
                 IMN=c("Nos1","Kcnab1",
                       "Gfra1","Etv1",
                       #"Man1a","Airn",
                       "Adcy2","Cmah","Col25a1",
                       "Mid1","Creb5","Vip","Pde1a",
                       "Ebf1",#,"Gpc5"
                       "Ppara","Pcdh11x",
                       "Adcy8","Grp"
                       ),
                 IN=c("Npas3","Synpr","St18","Gal",
                      "Cdh10","Neurod6",
                      "Kcnk13",
                      "Moxd1","Sctr",
                      "Piezo1","Vipr2","Sst",#"Adamts9",
                      "Kcnn2"
                      ),
                 IPAN=c("Calb2","Adcy1",
                        "Nmu","Adgrg6",#"Pcdh10",
                        "Ngfr","Il7",
                        "Itgb6","Calcb","Galr1",
                        #"Aff2",
                        #"Gpr149",
                        "Met",
                        "Cpne4","Cdh6","Cdh8",
                        "Clstn2",#"Ano2","Ntrk3",
                        #"Vwc2l",
                        "Car10","Scgn","Glp2r","Cck",
                        "Cdh9",
                        #"Vcan",
                        "Dcc",
                        "Gabrb1",
                        "Piezo2","Kcnh7",
                        #"Rerg",
                        "Bmpr1b","Ntng1","Skap1",
                        "Tafa2","Nxph2"))
pm.intAnno1.test0a <- DotPlot(GEX.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="All intAnno1")
pm.intAnno1.test0a

pm.intAnno2.test0a <- DotPlot(GEX.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="All intAnno2")
pm.intAnno2.test0a

pm.intAnno1.test0b <- DotPlot(GEX.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="All intAnno1")
pm.intAnno1.test0b

pm.intAnno2.test0b <- DotPlot(GEX.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="All intAnno2")
pm.intAnno2.test0b

pm.intAnno1.test1a <- DotPlot(test1.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno1")
pm.intAnno1.test1a

pm.intAnno2.test1a <- DotPlot(test1.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno2")
pm.intAnno2.test1a

pm.intAnno1.test1b <- DotPlot(test1.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno1")
pm.intAnno1.test1b

pm.intAnno2.test1b <- DotPlot(test1.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="PBSvsINF intAnno2")
pm.intAnno2.test1b

pm.intAnno1.test2a <- DotPlot(test2.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno1")
pm.intAnno1.test2a

pm.intAnno2.test2a <- DotPlot(test2.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno2")
pm.intAnno2.test2a

pm.intAnno1.test2b <- DotPlot(test2.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno1")
pm.intAnno1.test2b

pm.intAnno2.test2b <- DotPlot(test2.seur, features = as.vector(unlist(markers.new.s)), group.by = "intAnno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="CTLvsCKO intAnno2")
pm.intAnno2.test2b

pm.ref.a <- DotPlot(ref.seur, features = as.vector(unlist(markers.new.s)), group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  #coord_flip() +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + 
  scale_y_discrete(limits=rev) + 
  labs(title="NatNeur2021 P21")
pm.ref.a

pm.ref.b <- DotPlot(ref.seur, features = as.vector(unlist(markers.new.s)), group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  coord_flip() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.4,size = 9.15))+ 
  scale_color_gradientn(colours  = material.heat(100)) +
  #scale_x_discrete(limits=rev) + scale_y_discrete(limits=rev) + 
  labs(title="NatNeur2021 P21")
pm.ref.b

plot0727

repeat plot in 20230727

abreast violin plot to show markers: Il13ra1, Il4ra, Calca, Calcb, Nmu, Chat
modified violins and dots
PBS, INF separated
add wiocox.test in each intAnno

head(test1.seur@meta.data)
##                        orig.ident nCount_RNA nFeature_RNA percent.mt percent.rb
## AAACCCACAAGACGAC-1_1 Nb5d.PBS_INF       3257         1801 0.36843721  0.3991403
## AAACCCAGTGGGCTCT-1_1 Nb5d.PBS_INF       1511          997 0.66181337  0.4632694
## AAACCCAGTTTGTTCT-1_1 Nb5d.PBS_INF       2855         1577 0.98073555  0.3152364
## AAACCCATCCTAGCCT-1_1 Nb5d.PBS_INF       2433         1451 0.08220304  0.3699137
## AAACCCATCGAAACAA-1_1 Nb5d.PBS_INF       3129         1656 0.12783637  0.4474273
## AAACCCATCGGTCAGC-1_1 Nb5d.PBS_INF       2201         1294 0.22716947  0.2271695
##                           S.Score     G2M.Score Phase      cnt  rep newAnno
## AAACCCACAAGACGAC-1_1  0.011590405 -0.0004169865     S Nb5d.INF rep4    EMN3
## AAACCCAGTGGGCTCT-1_1 -0.024203070  0.0012414826   G2M Nb5d.PBS rep4   IPAN1
## AAACCCAGTTTGTTCT-1_1 -0.013980476  0.0039329410   G2M Nb5d.INF rep1    EMN3
## AAACCCATCCTAGCCT-1_1 -0.028925620 -0.0132582758    G1 Nb5d.INF rep2    EMN1
## AAACCCATCGAAACAA-1_1 -0.008077289 -0.0028336129    G1 Nb5d.PBS rep3   IPAN4
## AAACCCATCGGTCAGC-1_1 -0.023612751  0.0327239644   G2M Nb5d.PBS rep4    EMN1
##                         sample tissue nCount_SCT nFeature_SCT condition
## AAACCCACAAGACGAC-1_1 Nb5d.INF4  Ileum       2592         1794   INF_CTL
## AAACCCAGTGGGCTCT-1_1 Nb5d.PBS4  Ileum       1694          996   PBS_CTL
## AAACCCAGTTTGTTCT-1_1 Nb5d.INF1  Ileum       2495         1576   INF_CTL
## AAACCCATCCTAGCCT-1_1 Nb5d.INF2  Ileum       2324         1451   INF_CTL
## AAACCCATCGAAACAA-1_1 Nb5d.PBS3  Ileum       2552         1646   PBS_CTL
## AAACCCATCGGTCAGC-1_1 Nb5d.PBS4  Ileum       2171         1293   PBS_CTL
##                      seurat_clusters sort_clusters intAnno1 intAnno2
## AAACCCACAAGACGAC-1_1              11            11     EMN2     EMN2
## AAACCCAGTGGGCTCT-1_1              22            22    IPAN1  IPAN1.1
## AAACCCAGTTTGTTCT-1_1              11            11     EMN2     EMN2
## AAACCCATCCTAGCCT-1_1               4             4     EMN1     EMN1
## AAACCCATCGAAACAA-1_1              19            19    IPAN4    IPAN4
## AAACCCATCGGTCAGC-1_1               8             8     EMN1     EMN1
##                       score.EMN1   score.EMN2  score.EMN3  score.EMN4
## AAACCCACAAGACGAC-1_1  0.07919591  0.241706810  0.27217296  0.12854583
## AAACCCAGTGGGCTCT-1_1 -0.15104916 -0.182227557 -0.08972356 -0.02780619
## AAACCCAGTTTGTTCT-1_1  0.06398507  0.271974508  0.38593823  0.13952419
## AAACCCATCCTAGCCT-1_1  0.45628820  0.004121058 -0.09053160 -0.25144656
## AAACCCATCGAAACAA-1_1 -0.22677892 -0.176042364  0.17667288  0.07109063
## AAACCCATCGGTCAGC-1_1  0.41500886  0.078972206 -0.04352445 -0.01717643
##                        score.EMN5   score.IMN1   score.IMN2  score.IMN3
## AAACCCACAAGACGAC-1_1  0.112776596 -0.048743641  0.087677011 -0.06945631
## AAACCCAGTGGGCTCT-1_1 -0.078949105 -0.164458377 -0.010275168  0.03123894
## AAACCCAGTTTGTTCT-1_1  0.076261976  0.013262972 -0.086306052 -0.16199490
## AAACCCATCCTAGCCT-1_1 -0.014058236 -0.106028650 -0.055285442 -0.12949849
## AAACCCATCGAAACAA-1_1  0.102718840 -0.004683565 -0.006606094 -0.07936345
## AAACCCATCGGTCAGC-1_1 -0.008261381 -0.105501039  0.053248882 -0.05854380
##                        score.IMN4    score.IN1   score.IN2   score.IN3
## AAACCCACAAGACGAC-1_1  0.002799472 -0.052584879 -0.04337769  0.02522416
## AAACCCAGTGGGCTCT-1_1 -0.082036820 -0.107881694 -0.07353192  0.06210550
## AAACCCAGTTTGTTCT-1_1 -0.030034210 -0.109808107 -0.05886169  0.03389016
## AAACCCATCCTAGCCT-1_1 -0.079803316 -0.135613705 -0.12109194  0.16525651
## AAACCCATCGAAACAA-1_1 -0.014348463 -0.053893573  0.11275158 -0.04386948
## AAACCCATCGGTCAGC-1_1 -0.066043337 -0.004224746  0.01935024  0.07307944
##                      score.IPAN1.1 score.IPAN1.2 score.IPAN2.1 score.IPAN2.2
## AAACCCACAAGACGAC-1_1   -0.06921930   -0.05854091   -0.12090052   -0.03200085
## AAACCCAGTGGGCTCT-1_1    0.39874813    0.50626549    0.08046528   -0.05788911
## AAACCCAGTTTGTTCT-1_1   -0.10141645   -0.04456315   -0.04661481    0.01507260
## AAACCCATCCTAGCCT-1_1   -0.02942262   -0.11171721   -0.08567541   -0.03353428
## AAACCCATCGAAACAA-1_1    0.01651234   -0.01855972    0.11727520    0.26751667
## AAACCCATCGGTCAGC-1_1   -0.08079498   -0.09590834   -0.06355259    0.07461285
##                       score.IPAN3  score.IPAN4 score.INFxCTL_IPAN1
## AAACCCACAAGACGAC-1_1  0.009074399 -0.033702006          0.02559085
## AAACCCAGTGGGCTCT-1_1  0.075643417 -0.066791575          0.10998073
## AAACCCAGTTTGTTCT-1_1  0.023826742  0.025015471         -0.01209398
## AAACCCATCCTAGCCT-1_1  0.011699673 -0.003267128          0.03061715
## AAACCCATCGAAACAA-1_1  0.161399262  0.714055897         -0.02355308
## AAACCCATCGGTCAGC-1_1 -0.100991813  0.072239711          0.03672466
##                      score.INFxCTL_IPAN2 score.All_PBSup score.All_INFup
## AAACCCACAAGACGAC-1_1          0.03219975     0.038754467      0.14092349
## AAACCCAGTGGGCTCT-1_1          0.01085557     0.141496754      0.15347058
## AAACCCAGTTTGTTCT-1_1          0.07094068     0.042089530      0.11806283
## AAACCCATCCTAGCCT-1_1         -0.10919176     0.089116669      0.07064033
## AAACCCATCGAAACAA-1_1          0.10012150    -0.068982944      0.09493913
## AAACCCATCGGTCAGC-1_1         -0.13022208     0.005274842      0.09648734
##                      score.All_CTLup score.All_CKOup score.IPAN1_PBSup
## AAACCCACAAGACGAC-1_1      0.04699572      0.12328759       -0.07772672
## AAACCCAGTGGGCTCT-1_1      0.16455231      0.27409426        0.83477666
## AAACCCAGTTTGTTCT-1_1      0.02675111      0.04651514       -0.04362891
## AAACCCATCCTAGCCT-1_1     -0.06082137      0.17571025       -0.02777775
## AAACCCATCGAAACAA-1_1     -0.06550854     -0.04899024        0.16010606
## AAACCCATCGGTCAGC-1_1     -0.14775899      0.24252663        0.05487237
##                      score.IPAN1_INFup score.IPAN1_CTLup score.IPAN1_CKOup
## AAACCCACAAGACGAC-1_1        0.09536479       0.005898024       -0.08990901
## AAACCCAGTGGGCTCT-1_1        0.09832854       0.142199961        0.95544282
## AAACCCAGTTTGTTCT-1_1        0.05657979      -0.036408520       -0.07090544
## AAACCCATCCTAGCCT-1_1        0.02614203       0.014353383       -0.20984452
## AAACCCATCGAAACAA-1_1        0.04713297      -0.020370635        0.21988923
## AAACCCATCGGTCAGC-1_1        0.09156870       0.008539614       -0.00446080
##                      score.IPAN2_PBSup score.IPAN2_INFup score.IPAN2_CTLup
## AAACCCACAAGACGAC-1_1        0.23986616        0.09934860        0.03204373
## AAACCCAGTGGGCTCT-1_1        0.46980201       -0.02241394        0.03228071
## AAACCCAGTTTGTTCT-1_1        0.18824079        0.10546492        0.07251113
## AAACCCATCCTAGCCT-1_1       -0.12377840       -0.04855095       -0.09076901
## AAACCCATCGAAACAA-1_1        0.19893775        0.05686627        0.05049066
## AAACCCATCGGTCAGC-1_1        0.07972086       -0.01931504       -0.13585336
##                      score.IPAN2_CKOup  score.IEGs
## AAACCCACAAGACGAC-1_1       -0.30729036  0.13012508
## AAACCCAGTGGGCTCT-1_1        0.58710490  0.01972603
## AAACCCAGTTTGTTCT-1_1       -0.29511538 -0.01351550
## AAACCCATCCTAGCCT-1_1       -0.43075122 -0.02168908
## AAACCCATCGAAACAA-1_1       -0.14695600  0.01547855
## AAACCCATCGGTCAGC-1_1       -0.02570226 -0.01439351

mod metadata

cnt1

# cnt1 as PBS/INF           
test1.seur$cnt1 <- as.character(test1.seur$cnt)

test1.seur$cnt1 <- gsub("Nb5d.","",test1.seur$cnt1)

test1.seur$cnt1 <- factor(test1.seur$cnt1,
                          levels = c("PBS","INF"))

head(test1.seur$cnt1)
## AAACCCACAAGACGAC-1_1 AAACCCAGTGGGCTCT-1_1 AAACCCAGTTTGTTCT-1_1 
##                  INF                  PBS                  INF 
## AAACCCATCCTAGCCT-1_1 AAACCCATCGAAACAA-1_1 AAACCCATCGGTCAGC-1_1 
##                  INF                  PBS                  PBS 
## Levels: PBS INF

cnt2

levels(test1.seur$intAnno1)
##  [1] "EMN1"  "EMN2"  "EMN3"  "EMN4"  "EMN5"  "IMN1"  "IMN2"  "IMN3"  "IMN4" 
## [10] "IN1"   "IN2"   "IN3"   "IPAN1" "IPAN2" "IPAN3" "IPAN4"
level.cnt2 <- as.vector(sapply(levels(test1.seur$intAnno1),function(x){
  paste0(x,c(".PBS",".INF"))
}))
level.cnt2
##  [1] "EMN1.PBS"  "EMN1.INF"  "EMN2.PBS"  "EMN2.INF"  "EMN3.PBS"  "EMN3.INF" 
##  [7] "EMN4.PBS"  "EMN4.INF"  "EMN5.PBS"  "EMN5.INF"  "IMN1.PBS"  "IMN1.INF" 
## [13] "IMN2.PBS"  "IMN2.INF"  "IMN3.PBS"  "IMN3.INF"  "IMN4.PBS"  "IMN4.INF" 
## [19] "IN1.PBS"   "IN1.INF"   "IN2.PBS"   "IN2.INF"   "IN3.PBS"   "IN3.INF"  
## [25] "IPAN1.PBS" "IPAN1.INF" "IPAN2.PBS" "IPAN2.INF" "IPAN3.PBS" "IPAN3.INF"
## [31] "IPAN4.PBS" "IPAN4.INF"
# for violin comparison
list.cnt2 <- lapply(levels(test1.seur$intAnno1),function(x){
  paste0(x,c(".PBS",".INF"))
})
list.cnt2
## [[1]]
## [1] "EMN1.PBS" "EMN1.INF"
## 
## [[2]]
## [1] "EMN2.PBS" "EMN2.INF"
## 
## [[3]]
## [1] "EMN3.PBS" "EMN3.INF"
## 
## [[4]]
## [1] "EMN4.PBS" "EMN4.INF"
## 
## [[5]]
## [1] "EMN5.PBS" "EMN5.INF"
## 
## [[6]]
## [1] "IMN1.PBS" "IMN1.INF"
## 
## [[7]]
## [1] "IMN2.PBS" "IMN2.INF"
## 
## [[8]]
## [1] "IMN3.PBS" "IMN3.INF"
## 
## [[9]]
## [1] "IMN4.PBS" "IMN4.INF"
## 
## [[10]]
## [1] "IN1.PBS" "IN1.INF"
## 
## [[11]]
## [1] "IN2.PBS" "IN2.INF"
## 
## [[12]]
## [1] "IN3.PBS" "IN3.INF"
## 
## [[13]]
## [1] "IPAN1.PBS" "IPAN1.INF"
## 
## [[14]]
## [1] "IPAN2.PBS" "IPAN2.INF"
## 
## [[15]]
## [1] "IPAN3.PBS" "IPAN3.INF"
## 
## [[16]]
## [1] "IPAN4.PBS" "IPAN4.INF"
# cnt2 as intAnno1.PBS/INF
test1.seur$cnt2 <- factor(paste0(as.character(test1.seur$intAnno1),
                               ".",
                               as.character(test1.seur$cnt1)),
                        levels = level.cnt2)
head(test1.seur$cnt2)
## AAACCCACAAGACGAC-1_1 AAACCCAGTGGGCTCT-1_1 AAACCCAGTTTGTTCT-1_1 
##             EMN2.INF            IPAN1.PBS             EMN2.INF 
## AAACCCATCCTAGCCT-1_1 AAACCCATCGAAACAA-1_1 AAACCCATCGGTCAGC-1_1 
##             EMN1.INF            IPAN4.PBS             EMN1.PBS 
## 32 Levels: EMN1.PBS EMN1.INF EMN2.PBS EMN2.INF EMN3.PBS EMN3.INF ... IPAN4.INF

DEGs

# DEGs 
df_test1.DEGs_new <- read.csv("../integration_Nb5d/Baf53cre_Nb.DEGs.PBSvsINF.intAnno2.csv")
df_test1.DEGs_new$cluster <- factor(df_test1.DEGs_new$cluster,
                                    levels = c("Nb5d.PBS","Nb5d.INF"))
head(df_test1.DEGs_new)
##               X        p_val avg_log2FC pct.1 pct.2    p_val_adj  cluster
## 1        Ctnna3 8.684419e-51  0.4588045 0.846 0.761 2.129854e-46 Nb5d.PBS
## 2        Malat1 1.335552e-36  0.1410444 1.000 1.000 3.275441e-32 Nb5d.PBS
## 3      AY036118 7.553267e-24  0.2576808 0.788 0.750 1.852439e-19 Nb5d.PBS
## 4         Fgfr2 2.040025e-21  0.2291577 0.838 0.769 5.003161e-17 Nb5d.PBS
## 5 4930447N08Rik 2.483724e-18  0.2687259 0.726 0.659 6.091333e-14 Nb5d.PBS
## 6          Prkn 2.213112e-17  0.2764906 0.516 0.421 5.427657e-13 Nb5d.PBS
##            gene intAnno2
## 1        Ctnna3      All
## 2        Malat1      All
## 3      AY036118      All
## 4         Fgfr2      All
## 5 4930447N08Rik      All
## 6          Prkn      All
names_new <- unique(df_test1.DEGs_new$intAnno2)
names_new
##  [1] "All"     "EMNs"    "IMNs"    "IPAN1"   "IPAN2"   "EMN1"    "EMN2"   
##  [8] "EMN3"    "EMN4"    "EMN5"    "IMN1"    "IMN2"    "IMN3"    "IMN4"   
## [15] "IN1"     "IN2"     "IN3"     "IPAN1.1" "IPAN1.2" "IPAN2.1" "IPAN2.2"
## [22] "IPAN3"   "IPAN4"
options("max.print")
## $max.print
## [1] 99999
## cut1
cut.padj = 0.05
cut.log2FC = 0.3  
  
cut.pct1 = 0.1

df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN1") %>% as.data.frame()
##                  X         p_val avg_log2FC pct.1 pct.2     p_val_adj  cluster
## 1         Zfp804a1  2.807963e-43  0.9178380 0.997 0.983  6.886529e-39 Nb5d.PBS
## 2           Fgf131  2.599880e-39  0.8256163 1.000 0.993  6.376205e-35 Nb5d.PBS
## 3         Gm152611  1.174558e-27  1.2851620 0.865 0.583  2.880603e-23 Nb5d.PBS
## 4            Cdh61  2.345303e-27  0.8959969 0.926 0.806  5.751856e-23 Nb5d.PBS
## 5           Tafa11  3.531556e-21  0.5419270 1.000 0.986  8.661142e-17 Nb5d.PBS
## 6           Luzp21  8.214889e-20  1.2231915 0.623 0.288  2.014702e-15 Nb5d.PBS
## 7           Ppp3ca  3.160521e-18  0.5540905 0.968 0.934  7.751177e-14 Nb5d.PBS
## 8         Gm156801  3.777871e-16  1.1592365 0.480 0.194  9.265228e-12 Nb5d.PBS
## 9           Efr3a1  4.417514e-16  0.6065075 0.929 0.830  1.083395e-11 Nb5d.PBS
## 10           Lsamp  3.524202e-15  0.4351957 1.000 0.997  8.643106e-11 Nb5d.PBS
## 11        Arhgap61  4.007052e-13  0.9236485 0.628 0.392  9.827294e-09 Nb5d.PBS
## 12           Ano21  4.206697e-13  0.5683202 0.913 0.882  1.031692e-08 Nb5d.PBS
## 13         Filip11  8.818976e-13  0.5644433 0.945 0.844  2.162854e-08 Nb5d.PBS
## 14            Otof  1.540171e-12  0.9306861 0.393 0.142  3.777270e-08 Nb5d.PBS
## 15          Rab3c1  3.526455e-12  0.4683026 0.960 0.910  8.648632e-08 Nb5d.PBS
## 16         Rbfox11  1.360631e-10  0.3720548 1.000 0.997  3.336948e-06 Nb5d.PBS
## 17         Adgrg61  3.451285e-10  0.6935988 0.834 0.753  8.464277e-06 Nb5d.PBS
## 18         Ndufs12  5.810237e-10  0.8387902 0.404 0.188  1.424961e-05 Nb5d.PBS
## 19          Gpr851  5.990973e-10  0.7349275 0.488 0.260  1.469286e-05 Nb5d.PBS
## 20         Pdzrn41  1.691186e-09  0.6758964 0.757 0.625  4.147634e-05 Nb5d.PBS
## 21         Kctd121  3.142396e-09  0.6097306 0.256 0.076  7.706726e-05 Nb5d.PBS
## 22          Prom11  1.004221e-08  0.7204048 0.330 0.135  2.462852e-04 Nb5d.PBS
## 23         Gpr1491  1.440566e-08  0.5346354 0.823 0.736  3.532987e-04 Nb5d.PBS
## 24  1810034E14Rik1  1.878015e-08  0.6179254 0.612 0.385  4.605831e-04 Nb5d.PBS
## 25            Cnr1  4.017780e-08  0.4808448 0.868 0.778  9.853606e-04 Nb5d.PBS
## 26           Cntn5  5.943062e-08  0.4834572 1.000 1.000  1.457536e-03 Nb5d.PBS
## 27         Gm16541  6.603472e-08  0.7159641 0.575 0.396  1.619501e-03 Nb5d.PBS
## 28  D030068K23Rik1  9.186788e-08  0.6251514 0.485 0.271  2.253060e-03 Nb5d.PBS
## 29          Fgfr23  9.961633e-08  0.4728528 0.908 0.819  2.443090e-03 Nb5d.PBS
## 30        Gm287502  1.094314e-07  0.6274474 0.435 0.229  2.683804e-03 Nb5d.PBS
## 31          Rnf152  1.878742e-07  0.5153835 0.166 0.038  4.607614e-03 Nb5d.PBS
## 32           Kcnb2  3.121837e-07  0.5564509 0.976 0.979  7.656304e-03 Nb5d.PBS
## 33            Nme6  5.515540e-07  0.5636297 0.179 0.049  1.352686e-02 Nb5d.PBS
## 34   1700010I02Rik  7.585540e-07  0.4789062 0.153 0.035  1.860354e-02 Nb5d.PBS
## 35        Gm471532  8.109604e-07  0.4627286 0.124 0.021  1.988880e-02 Nb5d.PBS
## 36         Gm32335  8.849266e-07  0.6420728 0.530 0.351  2.170282e-02 Nb5d.PBS
## 37          Mef2c2  8.947898e-07  0.6108882 0.206 0.066  2.194472e-02 Nb5d.PBS
## 38           Dapk2  9.079763e-07  0.6353549 0.485 0.312  2.226812e-02 Nb5d.PBS
## 39   1110019D14Rik  1.175473e-06  0.6239660 0.230 0.083  2.882847e-02 Nb5d.PBS
## 40   A330008L17Rik  1.204074e-06  0.6815908 0.269 0.135  2.952990e-02 Nb5d.PBS
## 41           P2rx2  1.645730e-06  0.5339780 0.396 0.212  4.036154e-02 Nb5d.PBS
## 42          Hs3st5  1.920171e-06  0.3604601 0.881 0.823  4.709220e-02 Nb5d.PBS
## 43          Parm12 1.075991e-104  2.1724505 0.931 0.493 2.638869e-100 Nb5d.INF
## 44            Nmu1  2.136217e-82  2.0692761 0.962 0.546  5.239073e-78 Nb5d.INF
## 45          Cadm22  2.247800e-73  2.6501830 0.819 0.285  5.512730e-69 Nb5d.INF
## 46          Sgip11  7.278459e-69  1.3828413 0.965 0.789  1.785042e-64 Nb5d.INF
## 47            App1  1.928396e-66  1.4019565 0.965 0.768  4.729391e-62 Nb5d.INF
## 48        Fam155a3  5.924580e-64  1.1345751 1.000 0.989  1.453003e-59 Nb5d.INF
## 49           Dgki1  8.188198e-60  0.9389057 1.000 0.997  2.008156e-55 Nb5d.INF
## 50  4930432L08Rik1  4.960967e-58  2.0677918 0.847 0.401  1.216677e-53 Nb5d.INF
## 51          Kcnh82  9.483323e-51  1.9055502 0.642 0.137  2.325785e-46 Nb5d.INF
## 52           Gng21  2.747814e-48  1.4543326 0.833 0.533  6.739014e-44 Nb5d.INF
## 53         Cacnb41  1.137876e-43  1.6083705 0.691 0.266  2.790640e-39 Nb5d.INF
## 54        Hnrnpll1  1.164547e-42  1.5964868 0.615 0.179  2.856051e-38 Nb5d.INF
## 55        Col24a11  2.666312e-40  2.6309109 0.385 0.016  6.539131e-36 Nb5d.INF
## 56        Gm268712  3.622215e-40  0.8745574 0.986 0.950  8.883482e-36 Nb5d.INF
## 57            Alk2  2.235025e-34  1.8410770 0.635 0.277  5.481399e-30 Nb5d.INF
## 58          Calcb1  3.010440e-34  1.2126176 0.833 0.615  7.383104e-30 Nb5d.INF
## 59          Asxl31  3.433278e-34  1.3130268 0.639 0.216  8.420115e-30 Nb5d.INF
## 60         Tmeff21  2.592977e-33  1.0129207 0.955 0.934  6.359276e-29 Nb5d.INF
## 61          Nell12  5.890455e-32  0.9233766 0.927 0.807  1.444634e-27 Nb5d.INF
## 62          Pcsk22  1.580598e-31  1.0221099 0.882 0.786  3.876417e-27 Nb5d.INF
## 63         Abi3bp1  6.445359e-29  1.5634638 0.410 0.063  1.580724e-24 Nb5d.INF
## 64          Igf1r1  1.716889e-28  0.9882020 0.917 0.815  4.210671e-24 Nb5d.INF
## 65         Lingo22  2.992058e-28  0.8543086 0.997 0.979  7.338023e-24 Nb5d.INF
## 66            Dpyd  1.594534e-27  0.8040543 0.979 0.887  3.910595e-23 Nb5d.INF
## 67           Tll11  5.407854e-26  1.3664326 0.361 0.047  1.326276e-21 Nb5d.INF
## 68           Negr1  1.503459e-25  0.9415294 0.882 0.728  3.687234e-21 Nb5d.INF
## 69           Dysf1  6.038896e-24  1.3775355 0.583 0.288  1.481039e-19 Nb5d.INF
## 70           Syt91  1.700982e-23  0.9292975 0.826 0.641  4.171659e-19 Nb5d.INF
## 71        Gm300941  2.054852e-23  1.3294833 0.351 0.055  5.039524e-19 Nb5d.INF
## 72          Scn3a1  2.128004e-23  0.8035418 0.906 0.770  5.218930e-19 Nb5d.INF
## 73          Epha71  1.243026e-22  1.3068367 0.469 0.140  3.048520e-18 Nb5d.INF
## 74           Itih5  2.987203e-22  0.9396656 0.240 0.011  7.326115e-18 Nb5d.INF
## 75            Syt1  1.980907e-21  0.5812574 0.990 0.987  4.858173e-17 Nb5d.INF
## 76           Dgkg1  5.824735e-21  0.5318450 0.990 0.982  1.428516e-16 Nb5d.INF
## 77          Ppm1h2  6.613761e-21  0.8237434 0.882 0.707  1.622025e-16 Nb5d.INF
## 78          Ctnnd2  1.919416e-19  0.8719439 0.788 0.541  4.707367e-15 Nb5d.INF
## 79        Galnt131  2.130175e-19  1.0822264 0.708 0.501  5.224254e-15 Nb5d.INF
## 80         Gm12709  3.326302e-19  1.0902550 0.601 0.361  8.157756e-15 Nb5d.INF
## 81  1700111E14Rik1  4.880224e-19  0.7344907 0.934 0.950  1.196875e-14 Nb5d.INF
## 82           Epha6  1.668328e-18  0.9320389 0.795 0.649  4.091574e-14 Nb5d.INF
## 83          Rcan31  3.345314e-18  0.9868467 0.431 0.150  8.204383e-14 Nb5d.INF
## 84          Ptchd4  1.549455e-17  0.7943816 0.188 0.008  3.800038e-13 Nb5d.INF
## 85         Rab27b1  1.699653e-17  1.0190557 0.628 0.467  4.168399e-13 Nb5d.INF
## 86         Gm38405  1.702483e-17  1.4303310 0.191 0.011  4.175340e-13 Nb5d.INF
## 87       Ppp1r12b1  4.474937e-17  0.7289944 0.851 0.683  1.097478e-12 Nb5d.INF
## 88          Kif5a1  1.926266e-16  0.7521534 0.837 0.665  4.724166e-12 Nb5d.INF
## 89           Pak71  3.402264e-16  0.7740531 0.792 0.609  8.344053e-12 Nb5d.INF
## 90           Dner2  4.474026e-16  0.9619404 0.441 0.169  1.097255e-11 Nb5d.INF
## 91           Trhde  5.593460e-16  0.6860635 0.149 0.003  1.371796e-11 Nb5d.INF
## 92          Tmcc32  1.420198e-15  1.0647123 0.444 0.172  3.483036e-11 Nb5d.INF
## 93           Fhl11  1.595311e-15  0.9481742 0.559 0.317  3.912501e-11 Nb5d.INF
## 94          Dclk12  3.483586e-15  0.7298482 0.844 0.710  8.543495e-11 Nb5d.INF
## 95           Gria4  5.262180e-15  0.8870638 0.688 0.470  1.290550e-10 Nb5d.INF
## 96            Grp1  1.017341e-14  0.8228428 0.267 0.050  2.495029e-10 Nb5d.INF
## 97            Gpc6  2.869327e-14  1.4548572 0.615 0.383  7.037024e-10 Nb5d.INF
## 98           Adcy2  3.184482e-14  0.7526644 0.205 0.024  7.809942e-10 Nb5d.INF
## 99            Galm  6.957875e-14  0.7771259 0.205 0.029  1.706419e-09 Nb5d.INF
## 100          Aff23  7.761133e-14  0.5975160 0.875 0.699  1.903418e-09 Nb5d.INF
## 101        Map3k31  8.886742e-14  0.8545849 0.552 0.332  2.179473e-09 Nb5d.INF
## 102       Gm218471  1.445379e-12  0.5821607 0.812 0.551  3.544791e-08 Nb5d.INF
## 103         Rock11  4.300319e-12  0.7451907 0.674 0.475  1.054653e-07 Nb5d.INF
## 104         Apbb21  6.333930e-12  0.7920275 0.524 0.309  1.553396e-07 Nb5d.INF
## 105        Adam121  6.450169e-12  0.8857523 0.420 0.201  1.581904e-07 Nb5d.INF
## 106         Kcnt21  6.869812e-12  0.6137030 0.934 0.894  1.684821e-07 Nb5d.INF
## 107          Kcna4  6.995028e-12  0.7228218 0.215 0.045  1.715531e-07 Nb5d.INF
## 108          Myo3b  8.083859e-12  1.0179703 0.167 0.018  1.982566e-07 Nb5d.INF
## 109           Meg3  9.013449e-12  0.3131038 1.000 1.000  2.210548e-07 Nb5d.INF
## 110        Gm16158  2.216743e-11  0.7599130 0.201 0.040  5.436563e-07 Nb5d.INF
## 111         Bmpr21  2.647548e-11  0.6808265 0.632 0.456  6.493112e-07 Nb5d.INF
## 112         Mgat52  4.044154e-11  0.6689303 0.493 0.343  9.918288e-07 Nb5d.INF
## 113       Slco3a12  4.187152e-11  0.7235636 0.733 0.644  1.026899e-06 Nb5d.INF
## 114         Raph11  4.334610e-11  0.7335959 0.611 0.383  1.063063e-06 Nb5d.INF
## 115       Stxbp5l1  5.360225e-11  0.5304509 0.740 0.673  1.314595e-06 Nb5d.INF
## 116        Large12  5.533504e-11  0.7115061 0.760 0.654  1.357092e-06 Nb5d.INF
## 117         Trpm71  7.170477e-11  0.6973080 0.597 0.361  1.758560e-06 Nb5d.INF
## 118        Antxr21  8.919431e-11  0.8469972 0.392 0.195  2.187491e-06 Nb5d.INF
## 119       Gm269173  1.344304e-10  0.7888886 0.722 0.604  3.296906e-06 Nb5d.INF
## 120        Gm49226  2.864540e-10  0.7784810 0.378 0.169  7.025283e-06 Nb5d.INF
## 121      Atp6v0a11  3.306303e-10  0.5350307 0.865 0.715  8.108707e-06 Nb5d.INF
## 122         Rad51b  5.457911e-10  0.7331041 0.177 0.032  1.338553e-05 Nb5d.INF
## 123       Gucy1a22  6.271109e-10  0.6683144 0.701 0.522  1.537990e-05 Nb5d.INF
## 124           Grm7  1.107330e-09  0.6650001 0.740 0.668  2.715727e-05 Nb5d.INF
## 125        Iqgap21  1.277660e-09  0.5961049 0.667 0.536  3.133460e-05 Nb5d.INF
## 126 9530059O14Rik2  1.362684e-09  0.4010472 0.986 0.974  3.341983e-05 Nb5d.INF
## 127        Fam117a  3.004610e-09  0.7980456 0.326 0.140  7.368806e-05 Nb5d.INF
## 128        Arpp211  3.073181e-09  0.8474036 0.358 0.172  7.536977e-05 Nb5d.INF
## 129           Klf6  4.095137e-09  0.6453736 0.403 0.193  1.004332e-04 Nb5d.INF
## 130          Ubr51  5.958235e-09  0.5659184 0.830 0.697  1.461257e-04 Nb5d.INF
## 131       Nell1os1  6.082172e-09  0.7021925 0.608 0.475  1.491653e-04 Nb5d.INF
## 132          Cpne7  7.274987e-09  0.5685972 0.128 0.018  1.784191e-04 Nb5d.INF
## 133           Phip  1.182723e-08  0.6130820 0.549 0.398  2.900628e-04 Nb5d.INF
## 134        Gm43391  1.505672e-08  0.6543351 0.236 0.095  3.692660e-04 Nb5d.INF
## 135      Pcsk2os21  1.539838e-08  0.7221605 0.479 0.311  3.776452e-04 Nb5d.INF
## 136        Gm10791  1.592993e-08  0.6780872 0.271 0.100  3.906815e-04 Nb5d.INF
## 137           Adk1  1.725555e-08  0.7317618 0.333 0.187  4.231924e-04 Nb5d.INF
## 138          Grid1  1.935615e-08  0.6716949 0.552 0.388  4.747096e-04 Nb5d.INF
## 139        Gm48283  2.086099e-08  0.5560521 0.253 0.084  5.116158e-04 Nb5d.INF
## 140        Tmem8b1  3.154339e-08  0.6416565 0.531 0.343  7.736017e-04 Nb5d.INF
## 141         Golga4  3.658875e-08  0.6061004 0.444 0.248  8.973392e-04 Nb5d.INF
## 142          Edil3  6.552941e-08  0.5935189 0.750 0.652  1.607109e-03 Nb5d.INF
## 143            Fry  7.536168e-08  0.5946945 0.681 0.533  1.848245e-03 Nb5d.INF
## 144          Dlg22  8.927252e-08  0.3143282 0.990 0.982  2.189409e-03 Nb5d.INF
## 145        Ccser12  9.331096e-08  0.4890291 0.795 0.755  2.288451e-03 Nb5d.INF
## 146        Unc13b1  1.047124e-07  0.5866863 0.500 0.322  2.568072e-03 Nb5d.INF
## 147       Tctex1d1  1.370861e-07  0.4333606 0.118 0.021  3.362036e-03 Nb5d.INF
## 148        Gm32647  1.646828e-07  0.8128257 0.153 0.037  4.038846e-03 Nb5d.INF
## 149         Plppr5  1.767306e-07  0.5268661 0.646 0.538  4.334318e-03 Nb5d.INF
## 150       Gm217981  2.912692e-07  0.7666057 0.236 0.103  7.143376e-03 Nb5d.INF
## 151          Rgs72  3.159307e-07  0.5758945 0.507 0.346  7.748200e-03 Nb5d.INF
## 152         Lingo1  4.172889e-07  0.5468335 0.201 0.063  1.023401e-02 Nb5d.INF
## 153          Mpc12  4.291280e-07  0.4957475 0.476 0.372  1.052436e-02 Nb5d.INF
## 154        Dennd4a  4.327968e-07  0.6384667 0.382 0.222  1.061434e-02 Nb5d.INF
## 155         Syt142  4.349981e-07  0.4951693 0.611 0.493  1.066833e-02 Nb5d.INF
## 156         Dock71  4.458412e-07  0.5863511 0.490 0.338  1.093426e-02 Nb5d.INF
## 157          Mapk8  4.473014e-07  0.6126404 0.444 0.266  1.097007e-02 Nb5d.INF
## 158         Setbp1  4.595514e-07  0.6281453 0.215 0.077  1.127050e-02 Nb5d.INF
## 159         Plcl11  4.939162e-07  0.4664003 0.896 0.855  1.211329e-02 Nb5d.INF
## 160          Npr21  5.335064e-07  0.5091585 0.587 0.459  1.308424e-02 Nb5d.INF
## 161        Map7d11  5.786101e-07  0.6218713 0.562 0.401  1.419041e-02 Nb5d.INF
## 162         Vwc2l1  1.223733e-06  0.5511667 0.128 0.029  3.001206e-02 Nb5d.INF
## 163          Rai21  1.249040e-06  0.5761029 0.240 0.106  3.063269e-02 Nb5d.INF
## 164         Npy1r1  1.635777e-06  0.4674979 0.128 0.026  4.011743e-02 Nb5d.INF
## 165           Lhfp  1.747721e-06  0.5367612 0.188 0.090  4.286286e-02 Nb5d.INF
## 166          Golm1  1.980890e-06  0.4664170 0.260 0.108  4.858133e-02 Nb5d.INF
##              gene intAnno2
## 1         Zfp804a    IPAN1
## 2           Fgf13    IPAN1
## 3         Gm15261    IPAN1
## 4            Cdh6    IPAN1
## 5           Tafa1    IPAN1
## 6           Luzp2    IPAN1
## 7          Ppp3ca    IPAN1
## 8         Gm15680    IPAN1
## 9           Efr3a    IPAN1
## 10          Lsamp    IPAN1
## 11        Arhgap6    IPAN1
## 12           Ano2    IPAN1
## 13         Filip1    IPAN1
## 14           Otof    IPAN1
## 15          Rab3c    IPAN1
## 16         Rbfox1    IPAN1
## 17         Adgrg6    IPAN1
## 18         Ndufs1    IPAN1
## 19          Gpr85    IPAN1
## 20         Pdzrn4    IPAN1
## 21         Kctd12    IPAN1
## 22          Prom1    IPAN1
## 23         Gpr149    IPAN1
## 24  1810034E14Rik    IPAN1
## 25           Cnr1    IPAN1
## 26          Cntn5    IPAN1
## 27        Gm16541    IPAN1
## 28  D030068K23Rik    IPAN1
## 29          Fgfr2    IPAN1
## 30        Gm28750    IPAN1
## 31         Rnf152    IPAN1
## 32          Kcnb2    IPAN1
## 33           Nme6    IPAN1
## 34  1700010I02Rik    IPAN1
## 35        Gm47153    IPAN1
## 36        Gm32335    IPAN1
## 37          Mef2c    IPAN1
## 38          Dapk2    IPAN1
## 39  1110019D14Rik    IPAN1
## 40  A330008L17Rik    IPAN1
## 41          P2rx2    IPAN1
## 42         Hs3st5    IPAN1
## 43          Parm1    IPAN1
## 44            Nmu    IPAN1
## 45          Cadm2    IPAN1
## 46          Sgip1    IPAN1
## 47            App    IPAN1
## 48        Fam155a    IPAN1
## 49           Dgki    IPAN1
## 50  4930432L08Rik    IPAN1
## 51          Kcnh8    IPAN1
## 52           Gng2    IPAN1
## 53         Cacnb4    IPAN1
## 54        Hnrnpll    IPAN1
## 55        Col24a1    IPAN1
## 56        Gm26871    IPAN1
## 57            Alk    IPAN1
## 58          Calcb    IPAN1
## 59          Asxl3    IPAN1
## 60         Tmeff2    IPAN1
## 61          Nell1    IPAN1
## 62          Pcsk2    IPAN1
## 63         Abi3bp    IPAN1
## 64          Igf1r    IPAN1
## 65         Lingo2    IPAN1
## 66           Dpyd    IPAN1
## 67           Tll1    IPAN1
## 68          Negr1    IPAN1
## 69           Dysf    IPAN1
## 70           Syt9    IPAN1
## 71        Gm30094    IPAN1
## 72          Scn3a    IPAN1
## 73          Epha7    IPAN1
## 74          Itih5    IPAN1
## 75           Syt1    IPAN1
## 76           Dgkg    IPAN1
## 77          Ppm1h    IPAN1
## 78         Ctnnd2    IPAN1
## 79        Galnt13    IPAN1
## 80        Gm12709    IPAN1
## 81  1700111E14Rik    IPAN1
## 82          Epha6    IPAN1
## 83          Rcan3    IPAN1
## 84         Ptchd4    IPAN1
## 85         Rab27b    IPAN1
## 86        Gm38405    IPAN1
## 87       Ppp1r12b    IPAN1
## 88          Kif5a    IPAN1
## 89           Pak7    IPAN1
## 90           Dner    IPAN1
## 91          Trhde    IPAN1
## 92          Tmcc3    IPAN1
## 93           Fhl1    IPAN1
## 94          Dclk1    IPAN1
## 95          Gria4    IPAN1
## 96            Grp    IPAN1
## 97           Gpc6    IPAN1
## 98          Adcy2    IPAN1
## 99           Galm    IPAN1
## 100          Aff2    IPAN1
## 101        Map3k3    IPAN1
## 102       Gm21847    IPAN1
## 103         Rock1    IPAN1
## 104         Apbb2    IPAN1
## 105        Adam12    IPAN1
## 106         Kcnt2    IPAN1
## 107         Kcna4    IPAN1
## 108         Myo3b    IPAN1
## 109          Meg3    IPAN1
## 110       Gm16158    IPAN1
## 111         Bmpr2    IPAN1
## 112         Mgat5    IPAN1
## 113       Slco3a1    IPAN1
## 114         Raph1    IPAN1
## 115       Stxbp5l    IPAN1
## 116        Large1    IPAN1
## 117         Trpm7    IPAN1
## 118        Antxr2    IPAN1
## 119       Gm26917    IPAN1
## 120       Gm49226    IPAN1
## 121      Atp6v0a1    IPAN1
## 122        Rad51b    IPAN1
## 123       Gucy1a2    IPAN1
## 124          Grm7    IPAN1
## 125        Iqgap2    IPAN1
## 126 9530059O14Rik    IPAN1
## 127       Fam117a    IPAN1
## 128        Arpp21    IPAN1
## 129          Klf6    IPAN1
## 130          Ubr5    IPAN1
## 131       Nell1os    IPAN1
## 132         Cpne7    IPAN1
## 133          Phip    IPAN1
## 134       Gm43391    IPAN1
## 135      Pcsk2os2    IPAN1
## 136       Gm10791    IPAN1
## 137           Adk    IPAN1
## 138         Grid1    IPAN1
## 139       Gm48283    IPAN1
## 140        Tmem8b    IPAN1
## 141        Golga4    IPAN1
## 142         Edil3    IPAN1
## 143           Fry    IPAN1
## 144          Dlg2    IPAN1
## 145        Ccser1    IPAN1
## 146        Unc13b    IPAN1
## 147      Tctex1d1    IPAN1
## 148       Gm32647    IPAN1
## 149        Plppr5    IPAN1
## 150       Gm21798    IPAN1
## 151          Rgs7    IPAN1
## 152        Lingo1    IPAN1
## 153          Mpc1    IPAN1
## 154       Dennd4a    IPAN1
## 155         Syt14    IPAN1
## 156         Dock7    IPAN1
## 157         Mapk8    IPAN1
## 158        Setbp1    IPAN1
## 159         Plcl1    IPAN1
## 160          Npr2    IPAN1
## 161        Map7d1    IPAN1
## 162         Vwc2l    IPAN1
## 163          Rai2    IPAN1
## 164         Npy1r    IPAN1
## 165          Lhfp    IPAN1
## 166         Golm1    IPAN1
df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN2") %>% as.data.frame()  
##                 X        p_val avg_log2FC pct.1 pct.2    p_val_adj  cluster
## 1            Dgkb 8.984111e-21  0.8476953 0.981 0.939 2.203353e-16 Nb5d.PBS
## 2  4930428E07Rik1 2.238643e-15  1.1678282 0.723 0.490 5.490272e-11 Nb5d.PBS
## 3         Ctnna33 3.705546e-15  1.1143216 0.714 0.453 9.087853e-11 Nb5d.PBS
## 4         Malat14 1.550451e-13  0.3418027 1.000 1.000 3.802481e-09 Nb5d.PBS
## 5         Sema5a1 7.882569e-10  0.6222987 0.818 0.759 1.933200e-05 Nb5d.PBS
## 6        Gm152612 2.218453e-09  0.8561602 0.770 0.584 5.440756e-05 Nb5d.PBS
## 7  1700024B18Rik4 7.271022e-09  1.0441764 0.522 0.318 1.783218e-04 Nb5d.PBS
## 8           Cdh91 1.170528e-08  0.7985568 0.613 0.535 2.870721e-04 Nb5d.PBS
## 9        Gm162261 8.795125e-08  0.6955327 0.758 0.604 2.157004e-03 Nb5d.PBS
## 10        Gm11339 2.127904e-07  0.7890379 0.519 0.310 5.218685e-03 Nb5d.PBS
## 11      Serpini11 3.762577e-07  0.5357463 0.877 0.747 9.227720e-03 Nb5d.PBS
## 12        C797981 3.804951e-07  0.5481464 0.742 0.563 9.331642e-03 Nb5d.PBS
## 13           Vcan 5.321809e-07  0.6817009 0.579 0.429 1.305174e-02 Nb5d.PBS
## 14          Cdh62 5.383586e-07  0.8382672 0.569 0.437 1.320324e-02 Nb5d.PBS
## 15       Gm268733 1.106992e-06  0.6864560 0.198 0.053 2.714898e-02 Nb5d.PBS
## 16       Fam155a4 9.169076e-58  0.8699845 1.000 1.000 2.248716e-53 Nb5d.INF
## 17        Large13 7.059124e-57  1.9174776 0.914 0.591 1.731250e-52 Nb5d.INF
## 18       Gm306132 1.567105e-50  3.1018890 0.522 0.016 3.843326e-46 Nb5d.INF
## 19         Nrxn32 5.808554e-39  1.0873957 1.000 0.981 1.424548e-34 Nb5d.INF
## 20         Pcsk23 8.201326e-35  1.5194388 0.824 0.550 2.011375e-30 Nb5d.INF
## 21       Gm218472 3.677600e-34  2.0618649 0.437 0.031 9.019315e-30 Nb5d.INF
## 22        Ptprz11 1.245238e-24  1.4224892 0.384 0.047 3.053946e-20 Nb5d.INF
## 23         Kcnd22 1.267332e-23  1.1554087 0.882 0.698 3.108133e-19 Nb5d.INF
## 24           Alk3 2.283223e-23  0.6509571 1.000 0.981 5.599604e-19 Nb5d.INF
## 25         Calcb2 3.804532e-23  1.5970568 0.441 0.088 9.330614e-19 Nb5d.INF
## 26        Cacnb42 6.012505e-23  1.3984606 0.673 0.343 1.474567e-18 Nb5d.INF
## 27        Rab27b2 3.105717e-22  1.4279048 0.637 0.324 7.616770e-18 Nb5d.INF
## 28         Ppm1h3 1.240212e-20  0.9632908 0.869 0.648 3.041620e-16 Nb5d.INF
## 29         Tmcc33 2.770626e-19  1.3141965 0.588 0.236 6.794961e-15 Nb5d.INF
## 30       Gm217982 3.832938e-19  1.3822856 0.343 0.053 9.400280e-15 Nb5d.INF
## 31          Trpc3 5.466642e-19  1.2554502 0.400 0.088 1.340694e-14 Nb5d.INF
## 32        Arid5b1 8.050754e-18  1.0628226 0.727 0.459 1.974447e-13 Nb5d.INF
## 33         Nell13 2.710122e-16  1.2343783 0.637 0.384 6.646574e-12 Nb5d.INF
## 34         Dclk13 2.649230e-15  0.8906174 0.792 0.594 6.497236e-11 Nb5d.INF
## 35          Oxr13 9.306898e-15  0.9128341 0.878 0.673 2.282517e-10 Nb5d.INF
## 36         Sema3c 5.121192e-14  0.8772198 0.257 0.038 1.255972e-09 Nb5d.INF
## 37       Galnt132 5.502152e-14  0.5504102 0.992 0.969 1.349403e-09 Nb5d.INF
## 38       Gm300942 7.512355e-14  1.2692612 0.241 0.035 1.842405e-09 Nb5d.INF
## 39         Adcy82 8.634644e-14  0.9348883 0.241 0.035 2.117647e-09 Nb5d.INF
## 40          Dlg23 2.599861e-13  0.3869284 0.996 1.000 6.376159e-09 Nb5d.INF
## 41         Kcnq51 5.771307e-13  1.0223286 0.633 0.340 1.415413e-08 Nb5d.INF
## 42      Pcsk2os22 7.571718e-13  1.1267092 0.429 0.157 1.856964e-08 Nb5d.INF
## 43          Rgs73 2.245349e-11  0.7369429 0.751 0.538 5.506718e-07 Nb5d.INF
## 44         Asxl32 1.057437e-10  0.9250655 0.469 0.226 2.593365e-06 Nb5d.INF
## 45        Nkain22 2.101811e-10  0.7923540 0.780 0.569 5.154691e-06 Nb5d.INF
## 46       Stxbp5l2 2.810586e-10  0.4609672 0.963 0.921 6.892961e-06 Nb5d.INF
## 47          Csmd1 3.457238e-10  1.0416354 0.531 0.318 8.478876e-06 Nb5d.INF
## 48          Grm71 3.459586e-10  0.5185850 0.971 0.943 8.484635e-06 Nb5d.INF
## 49        Necab11 4.137618e-10  0.9119567 0.461 0.220 1.014751e-05 Nb5d.INF
## 50           App2 7.087319e-10  0.5494284 0.873 0.723 1.738165e-05 Nb5d.INF
## 51      Ppp1r12b2 7.961459e-10  0.7238245 0.653 0.475 1.952548e-05 Nb5d.INF
## 52          Dner3 1.561561e-09  0.6630562 0.812 0.619 3.829727e-05 Nb5d.INF
## 53         Cyyr13 2.378190e-09  0.7877871 0.310 0.101 5.832512e-05 Nb5d.INF
## 54         Scn3a2 3.010546e-09  0.7189504 0.731 0.544 7.383365e-05 Nb5d.INF
## 55          Fras1 6.568307e-09  0.7411780 0.196 0.038 1.610877e-04 Nb5d.INF
## 56          Dlc12 6.919855e-09  0.6193986 0.869 0.777 1.697094e-04 Nb5d.INF
## 57       Pcdh11x1 6.988003e-09  1.1498161 0.380 0.186 1.713808e-04 Nb5d.INF
## 58       Hnrnpll2 8.302118e-09  0.8569050 0.286 0.091 2.036094e-04 Nb5d.INF
## 59        Ptchd41 1.250139e-08  0.8004919 0.249 0.069 3.065965e-04 Nb5d.INF
## 60           Dmd1 1.653224e-08  0.6144068 0.890 0.780 4.054531e-04 Nb5d.INF
## 61        Antxr22 6.014578e-08  0.8743540 0.433 0.239 1.475075e-03 Nb5d.INF
## 62        Gabrg32 9.216211e-08  0.3587327 0.996 0.987 2.260276e-03 Nb5d.INF
## 63          Tll12 1.475759e-07  0.7194884 0.159 0.028 3.619298e-03 Nb5d.INF
## 64       Gucy1b11 2.667132e-07  0.7414708 0.371 0.170 6.541140e-03 Nb5d.INF
## 65           Hlf1 4.236502e-07  0.7802997 0.420 0.223 1.039002e-02 Nb5d.INF
## 66         Lrch12 4.276195e-07  0.6891340 0.306 0.123 1.048737e-02 Nb5d.INF
## 67       Col24a12 5.778937e-07  0.9348384 0.196 0.057 1.417284e-02 Nb5d.INF
## 68        Thsd7b3 6.464770e-07  0.7405743 0.620 0.453 1.585485e-02 Nb5d.INF
## 69         Cdh122 6.873839e-07  0.7159602 0.196 0.053 1.685809e-02 Nb5d.INF
## 70           Adk2 8.215702e-07  0.8327246 0.331 0.167 2.014901e-02 Nb5d.INF
## 71          Pkp42 1.050410e-06  0.6597114 0.535 0.368 2.576130e-02 Nb5d.INF
## 72        Unc13b2 1.072077e-06  0.6349907 0.506 0.327 2.629270e-02 Nb5d.INF
## 73        Col11a1 1.085435e-06  0.6554471 0.114 0.016 2.662028e-02 Nb5d.INF
## 74         Gria41 1.400895e-06  0.5285050 0.841 0.704 3.435695e-02 Nb5d.INF
## 75          Grid2 1.655054e-06  0.4222820 0.992 0.950 4.059020e-02 Nb5d.INF
## 76       Zdhhc143 1.716447e-06  0.5650068 0.473 0.264 4.209586e-02 Nb5d.INF
## 77        Prune23 1.831994e-06  0.4455636 0.951 0.884 4.492966e-02 Nb5d.INF
## 78          Ncam2 2.014743e-06  0.3925894 0.955 0.940 4.941158e-02 Nb5d.INF
##             gene intAnno2
## 1           Dgkb    IPAN2
## 2  4930428E07Rik    IPAN2
## 3         Ctnna3    IPAN2
## 4         Malat1    IPAN2
## 5         Sema5a    IPAN2
## 6        Gm15261    IPAN2
## 7  1700024B18Rik    IPAN2
## 8           Cdh9    IPAN2
## 9        Gm16226    IPAN2
## 10       Gm11339    IPAN2
## 11      Serpini1    IPAN2
## 12        C79798    IPAN2
## 13          Vcan    IPAN2
## 14          Cdh6    IPAN2
## 15       Gm26873    IPAN2
## 16       Fam155a    IPAN2
## 17        Large1    IPAN2
## 18       Gm30613    IPAN2
## 19         Nrxn3    IPAN2
## 20         Pcsk2    IPAN2
## 21       Gm21847    IPAN2
## 22        Ptprz1    IPAN2
## 23         Kcnd2    IPAN2
## 24           Alk    IPAN2
## 25         Calcb    IPAN2
## 26        Cacnb4    IPAN2
## 27        Rab27b    IPAN2
## 28         Ppm1h    IPAN2
## 29         Tmcc3    IPAN2
## 30       Gm21798    IPAN2
## 31         Trpc3    IPAN2
## 32        Arid5b    IPAN2
## 33         Nell1    IPAN2
## 34         Dclk1    IPAN2
## 35          Oxr1    IPAN2
## 36        Sema3c    IPAN2
## 37       Galnt13    IPAN2
## 38       Gm30094    IPAN2
## 39         Adcy8    IPAN2
## 40          Dlg2    IPAN2
## 41         Kcnq5    IPAN2
## 42      Pcsk2os2    IPAN2
## 43          Rgs7    IPAN2
## 44         Asxl3    IPAN2
## 45        Nkain2    IPAN2
## 46       Stxbp5l    IPAN2
## 47         Csmd1    IPAN2
## 48          Grm7    IPAN2
## 49        Necab1    IPAN2
## 50           App    IPAN2
## 51      Ppp1r12b    IPAN2
## 52          Dner    IPAN2
## 53         Cyyr1    IPAN2
## 54         Scn3a    IPAN2
## 55         Fras1    IPAN2
## 56          Dlc1    IPAN2
## 57       Pcdh11x    IPAN2
## 58       Hnrnpll    IPAN2
## 59        Ptchd4    IPAN2
## 60           Dmd    IPAN2
## 61        Antxr2    IPAN2
## 62        Gabrg3    IPAN2
## 63          Tll1    IPAN2
## 64       Gucy1b1    IPAN2
## 65           Hlf    IPAN2
## 66         Lrch1    IPAN2
## 67       Col24a1    IPAN2
## 68        Thsd7b    IPAN2
## 69         Cdh12    IPAN2
## 70           Adk    IPAN2
## 71          Pkp4    IPAN2
## 72        Unc13b    IPAN2
## 73       Col11a1    IPAN2
## 74         Gria4    IPAN2
## 75         Grid2    IPAN2
## 76       Zdhhc14    IPAN2
## 77        Prune2    IPAN2
## 78         Ncam2    IPAN2
pp.stat.DEG <- list()
pp.stat.DEG[[1]] <- df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                           abs(avg_log2FC) > cut.log2FC & 
                           pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>%
  summarise(up.DEGs = n()) %>% as.data.frame() %>%
  ggplot(aes(x=intAnno2, y=up.DEGs, color = cluster)) +
  geom_bar(stat="summary", fun="mean", position = position_dodge(0.75), width = 0.58, fill="white") +
  theme_classic(base_size = 15) +
  scale_color_manual(values = color.test1, name="") +
  labs(title=paste0("up.DEGs stat, pct.1>",cut.pct1,", padj<",cut.padj,", |log2FC|>",cut.log2FC), y = "Proportion") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 9.6),
        title =element_text(size=12, face='bold'))
## `summarise()` has grouped output by 'intAnno2'. You can override using the
## `.groups` argument.
pp.stat.DEG[[1]]

DEGs.IPAN1 <- (df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN1") %>% as.data.frame())$gene

DEGs.IPAN2 <- (df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN2") %>% as.data.frame())$gene
pp.cut1.IPAN1 <- DoHeatmap(subset(test1.seur, subset = intAnno1 == "IPAN1"), slot = "scale.data", disp.min = -1, disp.max = 2,
          features = DEGs.IPAN1[c(43:166,1:42)], group.by = "cnt1",
          group.colors = color.test1) + guides(color=FALSE) + theme(axis.text.y = element_text(size=2.25),
                                                                         plot.margin = unit(c(0.3,0.3,0.3,0.3),"cm")) +
  labs(title = "cut1, IPAN1")
pp.cut1.IPAN1

pp.cut1.IPAN2 <- DoHeatmap(subset(test1.seur, subset = intAnno1 == "IPAN2"), slot = "scale.data", disp.min = -1, disp.max = 2,
          features = DEGs.IPAN2[c(16:78,1:15)], group.by = "cnt1",
          group.colors = color.test1) + guides(color=FALSE) + theme(axis.text.y = element_text(size=2.4),
                                                                         plot.margin = unit(c(0.3,0.3,0.3,0.3),"cm")) +
  labs(title = "cut1, IPAN2")
pp.cut1.IPAN2

## cut2
cut.padj = 0.01
cut.log2FC = log2(1.5)  
  
cut.pct1 = 0.1

df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN1") %>% as.data.frame()
##                  X         p_val avg_log2FC pct.1 pct.2     p_val_adj  cluster
## 1         Zfp804a1  2.807963e-43  0.9178380 0.997 0.983  6.886529e-39 Nb5d.PBS
## 2           Fgf131  2.599880e-39  0.8256163 1.000 0.993  6.376205e-35 Nb5d.PBS
## 3         Gm152611  1.174558e-27  1.2851620 0.865 0.583  2.880603e-23 Nb5d.PBS
## 4            Cdh61  2.345303e-27  0.8959969 0.926 0.806  5.751856e-23 Nb5d.PBS
## 5           Luzp21  8.214889e-20  1.2231915 0.623 0.288  2.014702e-15 Nb5d.PBS
## 6         Gm156801  3.777871e-16  1.1592365 0.480 0.194  9.265228e-12 Nb5d.PBS
## 7           Efr3a1  4.417514e-16  0.6065075 0.929 0.830  1.083395e-11 Nb5d.PBS
## 8         Arhgap61  4.007052e-13  0.9236485 0.628 0.392  9.827294e-09 Nb5d.PBS
## 9             Otof  1.540171e-12  0.9306861 0.393 0.142  3.777270e-08 Nb5d.PBS
## 10         Adgrg61  3.451285e-10  0.6935988 0.834 0.753  8.464277e-06 Nb5d.PBS
## 11         Ndufs12  5.810237e-10  0.8387902 0.404 0.188  1.424961e-05 Nb5d.PBS
## 12          Gpr851  5.990973e-10  0.7349275 0.488 0.260  1.469286e-05 Nb5d.PBS
## 13         Pdzrn41  1.691186e-09  0.6758964 0.757 0.625  4.147634e-05 Nb5d.PBS
## 14         Kctd121  3.142396e-09  0.6097306 0.256 0.076  7.706726e-05 Nb5d.PBS
## 15          Prom11  1.004221e-08  0.7204048 0.330 0.135  2.462852e-04 Nb5d.PBS
## 16  1810034E14Rik1  1.878015e-08  0.6179254 0.612 0.385  4.605831e-04 Nb5d.PBS
## 17         Gm16541  6.603472e-08  0.7159641 0.575 0.396  1.619501e-03 Nb5d.PBS
## 18  D030068K23Rik1  9.186788e-08  0.6251514 0.485 0.271  2.253060e-03 Nb5d.PBS
## 19        Gm287502  1.094314e-07  0.6274474 0.435 0.229  2.683804e-03 Nb5d.PBS
## 20          Parm12 1.075991e-104  2.1724505 0.931 0.493 2.638869e-100 Nb5d.INF
## 21            Nmu1  2.136217e-82  2.0692761 0.962 0.546  5.239073e-78 Nb5d.INF
## 22          Cadm22  2.247800e-73  2.6501830 0.819 0.285  5.512730e-69 Nb5d.INF
## 23          Sgip11  7.278459e-69  1.3828413 0.965 0.789  1.785042e-64 Nb5d.INF
## 24            App1  1.928396e-66  1.4019565 0.965 0.768  4.729391e-62 Nb5d.INF
## 25        Fam155a3  5.924580e-64  1.1345751 1.000 0.989  1.453003e-59 Nb5d.INF
## 26           Dgki1  8.188198e-60  0.9389057 1.000 0.997  2.008156e-55 Nb5d.INF
## 27  4930432L08Rik1  4.960967e-58  2.0677918 0.847 0.401  1.216677e-53 Nb5d.INF
## 28          Kcnh82  9.483323e-51  1.9055502 0.642 0.137  2.325785e-46 Nb5d.INF
## 29           Gng21  2.747814e-48  1.4543326 0.833 0.533  6.739014e-44 Nb5d.INF
## 30         Cacnb41  1.137876e-43  1.6083705 0.691 0.266  2.790640e-39 Nb5d.INF
## 31        Hnrnpll1  1.164547e-42  1.5964868 0.615 0.179  2.856051e-38 Nb5d.INF
## 32        Col24a11  2.666312e-40  2.6309109 0.385 0.016  6.539131e-36 Nb5d.INF
## 33        Gm268712  3.622215e-40  0.8745574 0.986 0.950  8.883482e-36 Nb5d.INF
## 34            Alk2  2.235025e-34  1.8410770 0.635 0.277  5.481399e-30 Nb5d.INF
## 35          Calcb1  3.010440e-34  1.2126176 0.833 0.615  7.383104e-30 Nb5d.INF
## 36          Asxl31  3.433278e-34  1.3130268 0.639 0.216  8.420115e-30 Nb5d.INF
## 37         Tmeff21  2.592977e-33  1.0129207 0.955 0.934  6.359276e-29 Nb5d.INF
## 38          Nell12  5.890455e-32  0.9233766 0.927 0.807  1.444634e-27 Nb5d.INF
## 39          Pcsk22  1.580598e-31  1.0221099 0.882 0.786  3.876417e-27 Nb5d.INF
## 40         Abi3bp1  6.445359e-29  1.5634638 0.410 0.063  1.580724e-24 Nb5d.INF
## 41          Igf1r1  1.716889e-28  0.9882020 0.917 0.815  4.210671e-24 Nb5d.INF
## 42         Lingo22  2.992058e-28  0.8543086 0.997 0.979  7.338023e-24 Nb5d.INF
## 43            Dpyd  1.594534e-27  0.8040543 0.979 0.887  3.910595e-23 Nb5d.INF
## 44           Tll11  5.407854e-26  1.3664326 0.361 0.047  1.326276e-21 Nb5d.INF
## 45           Negr1  1.503459e-25  0.9415294 0.882 0.728  3.687234e-21 Nb5d.INF
## 46           Dysf1  6.038896e-24  1.3775355 0.583 0.288  1.481039e-19 Nb5d.INF
## 47           Syt91  1.700982e-23  0.9292975 0.826 0.641  4.171659e-19 Nb5d.INF
## 48        Gm300941  2.054852e-23  1.3294833 0.351 0.055  5.039524e-19 Nb5d.INF
## 49          Scn3a1  2.128004e-23  0.8035418 0.906 0.770  5.218930e-19 Nb5d.INF
## 50          Epha71  1.243026e-22  1.3068367 0.469 0.140  3.048520e-18 Nb5d.INF
## 51           Itih5  2.987203e-22  0.9396656 0.240 0.011  7.326115e-18 Nb5d.INF
## 52          Ppm1h2  6.613761e-21  0.8237434 0.882 0.707  1.622025e-16 Nb5d.INF
## 53          Ctnnd2  1.919416e-19  0.8719439 0.788 0.541  4.707367e-15 Nb5d.INF
## 54        Galnt131  2.130175e-19  1.0822264 0.708 0.501  5.224254e-15 Nb5d.INF
## 55         Gm12709  3.326302e-19  1.0902550 0.601 0.361  8.157756e-15 Nb5d.INF
## 56  1700111E14Rik1  4.880224e-19  0.7344907 0.934 0.950  1.196875e-14 Nb5d.INF
## 57           Epha6  1.668328e-18  0.9320389 0.795 0.649  4.091574e-14 Nb5d.INF
## 58          Rcan31  3.345314e-18  0.9868467 0.431 0.150  8.204383e-14 Nb5d.INF
## 59          Ptchd4  1.549455e-17  0.7943816 0.188 0.008  3.800038e-13 Nb5d.INF
## 60         Rab27b1  1.699653e-17  1.0190557 0.628 0.467  4.168399e-13 Nb5d.INF
## 61         Gm38405  1.702483e-17  1.4303310 0.191 0.011  4.175340e-13 Nb5d.INF
## 62       Ppp1r12b1  4.474937e-17  0.7289944 0.851 0.683  1.097478e-12 Nb5d.INF
## 63          Kif5a1  1.926266e-16  0.7521534 0.837 0.665  4.724166e-12 Nb5d.INF
## 64           Pak71  3.402264e-16  0.7740531 0.792 0.609  8.344053e-12 Nb5d.INF
## 65           Dner2  4.474026e-16  0.9619404 0.441 0.169  1.097255e-11 Nb5d.INF
## 66           Trhde  5.593460e-16  0.6860635 0.149 0.003  1.371796e-11 Nb5d.INF
## 67          Tmcc32  1.420198e-15  1.0647123 0.444 0.172  3.483036e-11 Nb5d.INF
## 68           Fhl11  1.595311e-15  0.9481742 0.559 0.317  3.912501e-11 Nb5d.INF
## 69          Dclk12  3.483586e-15  0.7298482 0.844 0.710  8.543495e-11 Nb5d.INF
## 70           Gria4  5.262180e-15  0.8870638 0.688 0.470  1.290550e-10 Nb5d.INF
## 71            Grp1  1.017341e-14  0.8228428 0.267 0.050  2.495029e-10 Nb5d.INF
## 72            Gpc6  2.869327e-14  1.4548572 0.615 0.383  7.037024e-10 Nb5d.INF
## 73           Adcy2  3.184482e-14  0.7526644 0.205 0.024  7.809942e-10 Nb5d.INF
## 74            Galm  6.957875e-14  0.7771259 0.205 0.029  1.706419e-09 Nb5d.INF
## 75           Aff23  7.761133e-14  0.5975160 0.875 0.699  1.903418e-09 Nb5d.INF
## 76         Map3k31  8.886742e-14  0.8545849 0.552 0.332  2.179473e-09 Nb5d.INF
## 77          Rock11  4.300319e-12  0.7451907 0.674 0.475  1.054653e-07 Nb5d.INF
## 78          Apbb21  6.333930e-12  0.7920275 0.524 0.309  1.553396e-07 Nb5d.INF
## 79         Adam121  6.450169e-12  0.8857523 0.420 0.201  1.581904e-07 Nb5d.INF
## 80          Kcnt21  6.869812e-12  0.6137030 0.934 0.894  1.684821e-07 Nb5d.INF
## 81           Kcna4  6.995028e-12  0.7228218 0.215 0.045  1.715531e-07 Nb5d.INF
## 82           Myo3b  8.083859e-12  1.0179703 0.167 0.018  1.982566e-07 Nb5d.INF
## 83         Gm16158  2.216743e-11  0.7599130 0.201 0.040  5.436563e-07 Nb5d.INF
## 84          Bmpr21  2.647548e-11  0.6808265 0.632 0.456  6.493112e-07 Nb5d.INF
## 85          Mgat52  4.044154e-11  0.6689303 0.493 0.343  9.918288e-07 Nb5d.INF
## 86        Slco3a12  4.187152e-11  0.7235636 0.733 0.644  1.026899e-06 Nb5d.INF
## 87          Raph11  4.334610e-11  0.7335959 0.611 0.383  1.063063e-06 Nb5d.INF
## 88         Large12  5.533504e-11  0.7115061 0.760 0.654  1.357092e-06 Nb5d.INF
## 89          Trpm71  7.170477e-11  0.6973080 0.597 0.361  1.758560e-06 Nb5d.INF
## 90         Antxr21  8.919431e-11  0.8469972 0.392 0.195  2.187491e-06 Nb5d.INF
## 91        Gm269173  1.344304e-10  0.7888886 0.722 0.604  3.296906e-06 Nb5d.INF
## 92         Gm49226  2.864540e-10  0.7784810 0.378 0.169  7.025283e-06 Nb5d.INF
## 93          Rad51b  5.457911e-10  0.7331041 0.177 0.032  1.338553e-05 Nb5d.INF
## 94        Gucy1a22  6.271109e-10  0.6683144 0.701 0.522  1.537990e-05 Nb5d.INF
## 95            Grm7  1.107330e-09  0.6650001 0.740 0.668  2.715727e-05 Nb5d.INF
## 96         Iqgap21  1.277660e-09  0.5961049 0.667 0.536  3.133460e-05 Nb5d.INF
## 97         Fam117a  3.004610e-09  0.7980456 0.326 0.140  7.368806e-05 Nb5d.INF
## 98         Arpp211  3.073181e-09  0.8474036 0.358 0.172  7.536977e-05 Nb5d.INF
## 99            Klf6  4.095137e-09  0.6453736 0.403 0.193  1.004332e-04 Nb5d.INF
## 100       Nell1os1  6.082172e-09  0.7021925 0.608 0.475  1.491653e-04 Nb5d.INF
## 101           Phip  1.182723e-08  0.6130820 0.549 0.398  2.900628e-04 Nb5d.INF
## 102        Gm43391  1.505672e-08  0.6543351 0.236 0.095  3.692660e-04 Nb5d.INF
## 103      Pcsk2os21  1.539838e-08  0.7221605 0.479 0.311  3.776452e-04 Nb5d.INF
## 104        Gm10791  1.592993e-08  0.6780872 0.271 0.100  3.906815e-04 Nb5d.INF
## 105           Adk1  1.725555e-08  0.7317618 0.333 0.187  4.231924e-04 Nb5d.INF
## 106          Grid1  1.935615e-08  0.6716949 0.552 0.388  4.747096e-04 Nb5d.INF
## 107        Tmem8b1  3.154339e-08  0.6416565 0.531 0.343  7.736017e-04 Nb5d.INF
## 108         Golga4  3.658875e-08  0.6061004 0.444 0.248  8.973392e-04 Nb5d.INF
## 109          Edil3  6.552941e-08  0.5935189 0.750 0.652  1.607109e-03 Nb5d.INF
## 110            Fry  7.536168e-08  0.5946945 0.681 0.533  1.848245e-03 Nb5d.INF
## 111        Unc13b1  1.047124e-07  0.5866863 0.500 0.322  2.568072e-03 Nb5d.INF
## 112        Gm32647  1.646828e-07  0.8128257 0.153 0.037  4.038846e-03 Nb5d.INF
## 113       Gm217981  2.912692e-07  0.7666057 0.236 0.103  7.143376e-03 Nb5d.INF
##              gene intAnno2
## 1         Zfp804a    IPAN1
## 2           Fgf13    IPAN1
## 3         Gm15261    IPAN1
## 4            Cdh6    IPAN1
## 5           Luzp2    IPAN1
## 6         Gm15680    IPAN1
## 7           Efr3a    IPAN1
## 8         Arhgap6    IPAN1
## 9            Otof    IPAN1
## 10         Adgrg6    IPAN1
## 11         Ndufs1    IPAN1
## 12          Gpr85    IPAN1
## 13         Pdzrn4    IPAN1
## 14         Kctd12    IPAN1
## 15          Prom1    IPAN1
## 16  1810034E14Rik    IPAN1
## 17        Gm16541    IPAN1
## 18  D030068K23Rik    IPAN1
## 19        Gm28750    IPAN1
## 20          Parm1    IPAN1
## 21            Nmu    IPAN1
## 22          Cadm2    IPAN1
## 23          Sgip1    IPAN1
## 24            App    IPAN1
## 25        Fam155a    IPAN1
## 26           Dgki    IPAN1
## 27  4930432L08Rik    IPAN1
## 28          Kcnh8    IPAN1
## 29           Gng2    IPAN1
## 30         Cacnb4    IPAN1
## 31        Hnrnpll    IPAN1
## 32        Col24a1    IPAN1
## 33        Gm26871    IPAN1
## 34            Alk    IPAN1
## 35          Calcb    IPAN1
## 36          Asxl3    IPAN1
## 37         Tmeff2    IPAN1
## 38          Nell1    IPAN1
## 39          Pcsk2    IPAN1
## 40         Abi3bp    IPAN1
## 41          Igf1r    IPAN1
## 42         Lingo2    IPAN1
## 43           Dpyd    IPAN1
## 44           Tll1    IPAN1
## 45          Negr1    IPAN1
## 46           Dysf    IPAN1
## 47           Syt9    IPAN1
## 48        Gm30094    IPAN1
## 49          Scn3a    IPAN1
## 50          Epha7    IPAN1
## 51          Itih5    IPAN1
## 52          Ppm1h    IPAN1
## 53         Ctnnd2    IPAN1
## 54        Galnt13    IPAN1
## 55        Gm12709    IPAN1
## 56  1700111E14Rik    IPAN1
## 57          Epha6    IPAN1
## 58          Rcan3    IPAN1
## 59         Ptchd4    IPAN1
## 60         Rab27b    IPAN1
## 61        Gm38405    IPAN1
## 62       Ppp1r12b    IPAN1
## 63          Kif5a    IPAN1
## 64           Pak7    IPAN1
## 65           Dner    IPAN1
## 66          Trhde    IPAN1
## 67          Tmcc3    IPAN1
## 68           Fhl1    IPAN1
## 69          Dclk1    IPAN1
## 70          Gria4    IPAN1
## 71            Grp    IPAN1
## 72           Gpc6    IPAN1
## 73          Adcy2    IPAN1
## 74           Galm    IPAN1
## 75           Aff2    IPAN1
## 76         Map3k3    IPAN1
## 77          Rock1    IPAN1
## 78          Apbb2    IPAN1
## 79         Adam12    IPAN1
## 80          Kcnt2    IPAN1
## 81          Kcna4    IPAN1
## 82          Myo3b    IPAN1
## 83        Gm16158    IPAN1
## 84          Bmpr2    IPAN1
## 85          Mgat5    IPAN1
## 86        Slco3a1    IPAN1
## 87          Raph1    IPAN1
## 88         Large1    IPAN1
## 89          Trpm7    IPAN1
## 90         Antxr2    IPAN1
## 91        Gm26917    IPAN1
## 92        Gm49226    IPAN1
## 93         Rad51b    IPAN1
## 94        Gucy1a2    IPAN1
## 95           Grm7    IPAN1
## 96         Iqgap2    IPAN1
## 97        Fam117a    IPAN1
## 98         Arpp21    IPAN1
## 99           Klf6    IPAN1
## 100       Nell1os    IPAN1
## 101          Phip    IPAN1
## 102       Gm43391    IPAN1
## 103      Pcsk2os2    IPAN1
## 104       Gm10791    IPAN1
## 105           Adk    IPAN1
## 106         Grid1    IPAN1
## 107        Tmem8b    IPAN1
## 108        Golga4    IPAN1
## 109         Edil3    IPAN1
## 110           Fry    IPAN1
## 111        Unc13b    IPAN1
## 112       Gm32647    IPAN1
## 113       Gm21798    IPAN1
df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN2") %>% as.data.frame()  
##                 X        p_val avg_log2FC pct.1 pct.2    p_val_adj  cluster
## 1            Dgkb 8.984111e-21  0.8476953 0.981 0.939 2.203353e-16 Nb5d.PBS
## 2  4930428E07Rik1 2.238643e-15  1.1678282 0.723 0.490 5.490272e-11 Nb5d.PBS
## 3         Ctnna33 3.705546e-15  1.1143216 0.714 0.453 9.087853e-11 Nb5d.PBS
## 4         Sema5a1 7.882569e-10  0.6222987 0.818 0.759 1.933200e-05 Nb5d.PBS
## 5        Gm152612 2.218453e-09  0.8561602 0.770 0.584 5.440756e-05 Nb5d.PBS
## 6  1700024B18Rik4 7.271022e-09  1.0441764 0.522 0.318 1.783218e-04 Nb5d.PBS
## 7           Cdh91 1.170528e-08  0.7985568 0.613 0.535 2.870721e-04 Nb5d.PBS
## 8        Gm162261 8.795125e-08  0.6955327 0.758 0.604 2.157004e-03 Nb5d.PBS
## 9         Gm11339 2.127904e-07  0.7890379 0.519 0.310 5.218685e-03 Nb5d.PBS
## 10       Fam155a4 9.169076e-58  0.8699845 1.000 1.000 2.248716e-53 Nb5d.INF
## 11        Large13 7.059124e-57  1.9174776 0.914 0.591 1.731250e-52 Nb5d.INF
## 12       Gm306132 1.567105e-50  3.1018890 0.522 0.016 3.843326e-46 Nb5d.INF
## 13         Nrxn32 5.808554e-39  1.0873957 1.000 0.981 1.424548e-34 Nb5d.INF
## 14         Pcsk23 8.201326e-35  1.5194388 0.824 0.550 2.011375e-30 Nb5d.INF
## 15       Gm218472 3.677600e-34  2.0618649 0.437 0.031 9.019315e-30 Nb5d.INF
## 16        Ptprz11 1.245238e-24  1.4224892 0.384 0.047 3.053946e-20 Nb5d.INF
## 17         Kcnd22 1.267332e-23  1.1554087 0.882 0.698 3.108133e-19 Nb5d.INF
## 18           Alk3 2.283223e-23  0.6509571 1.000 0.981 5.599604e-19 Nb5d.INF
## 19         Calcb2 3.804532e-23  1.5970568 0.441 0.088 9.330614e-19 Nb5d.INF
## 20        Cacnb42 6.012505e-23  1.3984606 0.673 0.343 1.474567e-18 Nb5d.INF
## 21        Rab27b2 3.105717e-22  1.4279048 0.637 0.324 7.616770e-18 Nb5d.INF
## 22         Ppm1h3 1.240212e-20  0.9632908 0.869 0.648 3.041620e-16 Nb5d.INF
## 23         Tmcc33 2.770626e-19  1.3141965 0.588 0.236 6.794961e-15 Nb5d.INF
## 24       Gm217982 3.832938e-19  1.3822856 0.343 0.053 9.400280e-15 Nb5d.INF
## 25          Trpc3 5.466642e-19  1.2554502 0.400 0.088 1.340694e-14 Nb5d.INF
## 26        Arid5b1 8.050754e-18  1.0628226 0.727 0.459 1.974447e-13 Nb5d.INF
## 27         Nell13 2.710122e-16  1.2343783 0.637 0.384 6.646574e-12 Nb5d.INF
## 28         Dclk13 2.649230e-15  0.8906174 0.792 0.594 6.497236e-11 Nb5d.INF
## 29          Oxr13 9.306898e-15  0.9128341 0.878 0.673 2.282517e-10 Nb5d.INF
## 30         Sema3c 5.121192e-14  0.8772198 0.257 0.038 1.255972e-09 Nb5d.INF
## 31       Gm300942 7.512355e-14  1.2692612 0.241 0.035 1.842405e-09 Nb5d.INF
## 32         Adcy82 8.634644e-14  0.9348883 0.241 0.035 2.117647e-09 Nb5d.INF
## 33         Kcnq51 5.771307e-13  1.0223286 0.633 0.340 1.415413e-08 Nb5d.INF
## 34      Pcsk2os22 7.571718e-13  1.1267092 0.429 0.157 1.856964e-08 Nb5d.INF
## 35          Rgs73 2.245349e-11  0.7369429 0.751 0.538 5.506718e-07 Nb5d.INF
## 36         Asxl32 1.057437e-10  0.9250655 0.469 0.226 2.593365e-06 Nb5d.INF
## 37        Nkain22 2.101811e-10  0.7923540 0.780 0.569 5.154691e-06 Nb5d.INF
## 38          Csmd1 3.457238e-10  1.0416354 0.531 0.318 8.478876e-06 Nb5d.INF
## 39        Necab11 4.137618e-10  0.9119567 0.461 0.220 1.014751e-05 Nb5d.INF
## 40      Ppp1r12b2 7.961459e-10  0.7238245 0.653 0.475 1.952548e-05 Nb5d.INF
## 41          Dner3 1.561561e-09  0.6630562 0.812 0.619 3.829727e-05 Nb5d.INF
## 42         Cyyr13 2.378190e-09  0.7877871 0.310 0.101 5.832512e-05 Nb5d.INF
## 43         Scn3a2 3.010546e-09  0.7189504 0.731 0.544 7.383365e-05 Nb5d.INF
## 44          Fras1 6.568307e-09  0.7411780 0.196 0.038 1.610877e-04 Nb5d.INF
## 45          Dlc12 6.919855e-09  0.6193986 0.869 0.777 1.697094e-04 Nb5d.INF
## 46       Pcdh11x1 6.988003e-09  1.1498161 0.380 0.186 1.713808e-04 Nb5d.INF
## 47       Hnrnpll2 8.302118e-09  0.8569050 0.286 0.091 2.036094e-04 Nb5d.INF
## 48        Ptchd41 1.250139e-08  0.8004919 0.249 0.069 3.065965e-04 Nb5d.INF
## 49           Dmd1 1.653224e-08  0.6144068 0.890 0.780 4.054531e-04 Nb5d.INF
## 50        Antxr22 6.014578e-08  0.8743540 0.433 0.239 1.475075e-03 Nb5d.INF
## 51          Tll12 1.475759e-07  0.7194884 0.159 0.028 3.619298e-03 Nb5d.INF
## 52       Gucy1b11 2.667132e-07  0.7414708 0.371 0.170 6.541140e-03 Nb5d.INF
##             gene intAnno2
## 1           Dgkb    IPAN2
## 2  4930428E07Rik    IPAN2
## 3         Ctnna3    IPAN2
## 4         Sema5a    IPAN2
## 5        Gm15261    IPAN2
## 6  1700024B18Rik    IPAN2
## 7           Cdh9    IPAN2
## 8        Gm16226    IPAN2
## 9        Gm11339    IPAN2
## 10       Fam155a    IPAN2
## 11        Large1    IPAN2
## 12       Gm30613    IPAN2
## 13         Nrxn3    IPAN2
## 14         Pcsk2    IPAN2
## 15       Gm21847    IPAN2
## 16        Ptprz1    IPAN2
## 17         Kcnd2    IPAN2
## 18           Alk    IPAN2
## 19         Calcb    IPAN2
## 20        Cacnb4    IPAN2
## 21        Rab27b    IPAN2
## 22         Ppm1h    IPAN2
## 23         Tmcc3    IPAN2
## 24       Gm21798    IPAN2
## 25         Trpc3    IPAN2
## 26        Arid5b    IPAN2
## 27         Nell1    IPAN2
## 28         Dclk1    IPAN2
## 29          Oxr1    IPAN2
## 30        Sema3c    IPAN2
## 31       Gm30094    IPAN2
## 32         Adcy8    IPAN2
## 33         Kcnq5    IPAN2
## 34      Pcsk2os2    IPAN2
## 35          Rgs7    IPAN2
## 36         Asxl3    IPAN2
## 37        Nkain2    IPAN2
## 38         Csmd1    IPAN2
## 39        Necab1    IPAN2
## 40      Ppp1r12b    IPAN2
## 41          Dner    IPAN2
## 42         Cyyr1    IPAN2
## 43         Scn3a    IPAN2
## 44         Fras1    IPAN2
## 45          Dlc1    IPAN2
## 46       Pcdh11x    IPAN2
## 47       Hnrnpll    IPAN2
## 48        Ptchd4    IPAN2
## 49           Dmd    IPAN2
## 50        Antxr2    IPAN2
## 51          Tll1    IPAN2
## 52       Gucy1b1    IPAN2
#pp.stat.DEG <- list()
pp.stat.DEG[[2]] <- df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                           abs(avg_log2FC) > cut.log2FC & 
                           pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>%
  summarise(up.DEGs = n()) %>% as.data.frame() %>%
  ggplot(aes(x=intAnno2, y=up.DEGs, color = cluster)) +
  geom_bar(stat="summary", fun="mean", position = position_dodge(0.75), width = 0.58, fill="white") +
  theme_classic(base_size = 15) +
  scale_color_manual(values = color.test1, name="") +
  labs(title=paste0("up.DEGs stat, pct.1>",cut.pct1,", padj<",cut.padj,", |log2FC|>","log2(1.5)"), y = "Proportion") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 9.6),
        title =element_text(size=12, face='bold'))
## `summarise()` has grouped output by 'intAnno2'. You can override using the
## `.groups` argument.
pp.stat.DEG[[2]]

DEGs.IPAN1 <- (df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN1") %>% as.data.frame())$gene

DEGs.IPAN2 <- (df_test1.DEGs_new %>% filter(p_val_adj < cut.padj & 
                       abs(avg_log2FC) > cut.log2FC & 
                       pct.1 > cut.pct1) %>%
  group_by(intAnno2,cluster) %>% filter ( intAnno2 == "IPAN2") %>% as.data.frame())$gene
pp.cut2.IPAN1 <- DoHeatmap(subset(test1.seur, subset = intAnno1 == "IPAN1"), slot = "scale.data", disp.min = -1, disp.max = 2,
          features = DEGs.IPAN1[c(20:113,1:19)], group.by = "cnt1",
          group.colors = color.test1) + guides(color=FALSE) + theme(axis.text.y = element_text(size=2.35),
                                                                         plot.margin = unit(c(0.3,0.3,0.3,0.3),"cm")) +
  labs(title = "cut2, IPAN1")
pp.cut2.IPAN1

pp.cut2.IPAN2 <- DoHeatmap(subset(test1.seur, subset = intAnno1 == "IPAN2"), slot = "scale.data", disp.min = -1, disp.max = 2,
          features = DEGs.IPAN2[c(10:52,1:9)], group.by = "cnt1",
          group.colors = color.test1) + guides(color=FALSE) + theme(axis.text.y = element_text(size = 2.35),
                                                                         plot.margin = unit(c(0.3,0.3,0.3,0.3),"cm")) +
  labs(title = "cut2, IPAN2")
pp.cut2.IPAN2

markers

check.plot <- c("Il13ra1","Il4ra","Calca","Calcb",
                "Nmu","Chat")

vln_df <- data.frame(test1.seur@meta.data,
                     t(test1.seur@assays$RNA@data[check.plot,]))

head(vln_df)
##                        orig.ident nCount_RNA nFeature_RNA percent.mt percent.rb
## AAACCCACAAGACGAC-1_1 Nb5d.PBS_INF       3257         1801 0.36843721  0.3991403
## AAACCCAGTGGGCTCT-1_1 Nb5d.PBS_INF       1511          997 0.66181337  0.4632694
## AAACCCAGTTTGTTCT-1_1 Nb5d.PBS_INF       2855         1577 0.98073555  0.3152364
## AAACCCATCCTAGCCT-1_1 Nb5d.PBS_INF       2433         1451 0.08220304  0.3699137
## AAACCCATCGAAACAA-1_1 Nb5d.PBS_INF       3129         1656 0.12783637  0.4474273
## AAACCCATCGGTCAGC-1_1 Nb5d.PBS_INF       2201         1294 0.22716947  0.2271695
##                           S.Score     G2M.Score Phase      cnt  rep newAnno
## AAACCCACAAGACGAC-1_1  0.011590405 -0.0004169865     S Nb5d.INF rep4    EMN3
## AAACCCAGTGGGCTCT-1_1 -0.024203070  0.0012414826   G2M Nb5d.PBS rep4   IPAN1
## AAACCCAGTTTGTTCT-1_1 -0.013980476  0.0039329410   G2M Nb5d.INF rep1    EMN3
## AAACCCATCCTAGCCT-1_1 -0.028925620 -0.0132582758    G1 Nb5d.INF rep2    EMN1
## AAACCCATCGAAACAA-1_1 -0.008077289 -0.0028336129    G1 Nb5d.PBS rep3   IPAN4
## AAACCCATCGGTCAGC-1_1 -0.023612751  0.0327239644   G2M Nb5d.PBS rep4    EMN1
##                         sample tissue nCount_SCT nFeature_SCT condition
## AAACCCACAAGACGAC-1_1 Nb5d.INF4  Ileum       2592         1794   INF_CTL
## AAACCCAGTGGGCTCT-1_1 Nb5d.PBS4  Ileum       1694          996   PBS_CTL
## AAACCCAGTTTGTTCT-1_1 Nb5d.INF1  Ileum       2495         1576   INF_CTL
## AAACCCATCCTAGCCT-1_1 Nb5d.INF2  Ileum       2324         1451   INF_CTL
## AAACCCATCGAAACAA-1_1 Nb5d.PBS3  Ileum       2552         1646   PBS_CTL
## AAACCCATCGGTCAGC-1_1 Nb5d.PBS4  Ileum       2171         1293   PBS_CTL
##                      seurat_clusters sort_clusters intAnno1 intAnno2
## AAACCCACAAGACGAC-1_1              11            11     EMN2     EMN2
## AAACCCAGTGGGCTCT-1_1              22            22    IPAN1  IPAN1.1
## AAACCCAGTTTGTTCT-1_1              11            11     EMN2     EMN2
## AAACCCATCCTAGCCT-1_1               4             4     EMN1     EMN1
## AAACCCATCGAAACAA-1_1              19            19    IPAN4    IPAN4
## AAACCCATCGGTCAGC-1_1               8             8     EMN1     EMN1
##                       score.EMN1   score.EMN2  score.EMN3  score.EMN4
## AAACCCACAAGACGAC-1_1  0.07919591  0.241706810  0.27217296  0.12854583
## AAACCCAGTGGGCTCT-1_1 -0.15104916 -0.182227557 -0.08972356 -0.02780619
## AAACCCAGTTTGTTCT-1_1  0.06398507  0.271974508  0.38593823  0.13952419
## AAACCCATCCTAGCCT-1_1  0.45628820  0.004121058 -0.09053160 -0.25144656
## AAACCCATCGAAACAA-1_1 -0.22677892 -0.176042364  0.17667288  0.07109063
## AAACCCATCGGTCAGC-1_1  0.41500886  0.078972206 -0.04352445 -0.01717643
##                        score.EMN5   score.IMN1   score.IMN2  score.IMN3
## AAACCCACAAGACGAC-1_1  0.112776596 -0.048743641  0.087677011 -0.06945631
## AAACCCAGTGGGCTCT-1_1 -0.078949105 -0.164458377 -0.010275168  0.03123894
## AAACCCAGTTTGTTCT-1_1  0.076261976  0.013262972 -0.086306052 -0.16199490
## AAACCCATCCTAGCCT-1_1 -0.014058236 -0.106028650 -0.055285442 -0.12949849
## AAACCCATCGAAACAA-1_1  0.102718840 -0.004683565 -0.006606094 -0.07936345
## AAACCCATCGGTCAGC-1_1 -0.008261381 -0.105501039  0.053248882 -0.05854380
##                        score.IMN4    score.IN1   score.IN2   score.IN3
## AAACCCACAAGACGAC-1_1  0.002799472 -0.052584879 -0.04337769  0.02522416
## AAACCCAGTGGGCTCT-1_1 -0.082036820 -0.107881694 -0.07353192  0.06210550
## AAACCCAGTTTGTTCT-1_1 -0.030034210 -0.109808107 -0.05886169  0.03389016
## AAACCCATCCTAGCCT-1_1 -0.079803316 -0.135613705 -0.12109194  0.16525651
## AAACCCATCGAAACAA-1_1 -0.014348463 -0.053893573  0.11275158 -0.04386948
## AAACCCATCGGTCAGC-1_1 -0.066043337 -0.004224746  0.01935024  0.07307944
##                      score.IPAN1.1 score.IPAN1.2 score.IPAN2.1 score.IPAN2.2
## AAACCCACAAGACGAC-1_1   -0.06921930   -0.05854091   -0.12090052   -0.03200085
## AAACCCAGTGGGCTCT-1_1    0.39874813    0.50626549    0.08046528   -0.05788911
## AAACCCAGTTTGTTCT-1_1   -0.10141645   -0.04456315   -0.04661481    0.01507260
## AAACCCATCCTAGCCT-1_1   -0.02942262   -0.11171721   -0.08567541   -0.03353428
## AAACCCATCGAAACAA-1_1    0.01651234   -0.01855972    0.11727520    0.26751667
## AAACCCATCGGTCAGC-1_1   -0.08079498   -0.09590834   -0.06355259    0.07461285
##                       score.IPAN3  score.IPAN4 score.INFxCTL_IPAN1
## AAACCCACAAGACGAC-1_1  0.009074399 -0.033702006          0.02559085
## AAACCCAGTGGGCTCT-1_1  0.075643417 -0.066791575          0.10998073
## AAACCCAGTTTGTTCT-1_1  0.023826742  0.025015471         -0.01209398
## AAACCCATCCTAGCCT-1_1  0.011699673 -0.003267128          0.03061715
## AAACCCATCGAAACAA-1_1  0.161399262  0.714055897         -0.02355308
## AAACCCATCGGTCAGC-1_1 -0.100991813  0.072239711          0.03672466
##                      score.INFxCTL_IPAN2 score.All_PBSup score.All_INFup
## AAACCCACAAGACGAC-1_1          0.03219975     0.038754467      0.14092349
## AAACCCAGTGGGCTCT-1_1          0.01085557     0.141496754      0.15347058
## AAACCCAGTTTGTTCT-1_1          0.07094068     0.042089530      0.11806283
## AAACCCATCCTAGCCT-1_1         -0.10919176     0.089116669      0.07064033
## AAACCCATCGAAACAA-1_1          0.10012150    -0.068982944      0.09493913
## AAACCCATCGGTCAGC-1_1         -0.13022208     0.005274842      0.09648734
##                      score.All_CTLup score.All_CKOup score.IPAN1_PBSup
## AAACCCACAAGACGAC-1_1      0.04699572      0.12328759       -0.07772672
## AAACCCAGTGGGCTCT-1_1      0.16455231      0.27409426        0.83477666
## AAACCCAGTTTGTTCT-1_1      0.02675111      0.04651514       -0.04362891
## AAACCCATCCTAGCCT-1_1     -0.06082137      0.17571025       -0.02777775
## AAACCCATCGAAACAA-1_1     -0.06550854     -0.04899024        0.16010606
## AAACCCATCGGTCAGC-1_1     -0.14775899      0.24252663        0.05487237
##                      score.IPAN1_INFup score.IPAN1_CTLup score.IPAN1_CKOup
## AAACCCACAAGACGAC-1_1        0.09536479       0.005898024       -0.08990901
## AAACCCAGTGGGCTCT-1_1        0.09832854       0.142199961        0.95544282
## AAACCCAGTTTGTTCT-1_1        0.05657979      -0.036408520       -0.07090544
## AAACCCATCCTAGCCT-1_1        0.02614203       0.014353383       -0.20984452
## AAACCCATCGAAACAA-1_1        0.04713297      -0.020370635        0.21988923
## AAACCCATCGGTCAGC-1_1        0.09156870       0.008539614       -0.00446080
##                      score.IPAN2_PBSup score.IPAN2_INFup score.IPAN2_CTLup
## AAACCCACAAGACGAC-1_1        0.23986616        0.09934860        0.03204373
## AAACCCAGTGGGCTCT-1_1        0.46980201       -0.02241394        0.03228071
## AAACCCAGTTTGTTCT-1_1        0.18824079        0.10546492        0.07251113
## AAACCCATCCTAGCCT-1_1       -0.12377840       -0.04855095       -0.09076901
## AAACCCATCGAAACAA-1_1        0.19893775        0.05686627        0.05049066
## AAACCCATCGGTCAGC-1_1        0.07972086       -0.01931504       -0.13585336
##                      score.IPAN2_CKOup  score.IEGs cnt1      cnt2 Il13ra1 Il4ra
## AAACCCACAAGACGAC-1_1       -0.30729036  0.13012508  INF  EMN2.INF       0     0
## AAACCCAGTGGGCTCT-1_1        0.58710490  0.01972603  PBS IPAN1.PBS       0     0
## AAACCCAGTTTGTTCT-1_1       -0.29511538 -0.01351550  INF  EMN2.INF       0     0
## AAACCCATCCTAGCCT-1_1       -0.43075122 -0.02168908  INF  EMN1.INF       0     0
## AAACCCATCGAAACAA-1_1       -0.14695600  0.01547855  PBS IPAN4.PBS       0     0
## AAACCCATCGGTCAGC-1_1       -0.02570226 -0.01439351  PBS  EMN1.PBS       0     0
##                      Calca    Calcb      Nmu     Chat
## AAACCCACAAGACGAC-1_1     0 0.000000 0.000000 0.000000
## AAACCCAGTGGGCTCT-1_1     0 2.030531 2.030531 0.000000
## AAACCCAGTTTGTTCT-1_1     0 0.000000 0.000000 0.000000
## AAACCCATCCTAGCCT-1_1     0 0.000000 0.000000 1.631229
## AAACCCATCGAAACAA-1_1     0 0.000000 0.000000 0.000000
## AAACCCATCGGTCAGC-1_1     0 0.000000 0.000000 0.000000
pp.vln <- list()

pp.vln <- lapply(1:5, function(jj){
  pp.tmp <- ggplot(vln_df, aes(x = cnt2, y= get(check.plot[jj]), fill = cnt1)) +
    geom_violin(trim = TRUE, scale = 'width', lwd=0.1) +
    labs(x="",y="",title=check.plot[jj]) + NoLegend() +
    #scale_fill_manual(values = ggsci::pal_d3("category20c")(20)[c(1,2)]) +
    scale_fill_manual(values = color.test1) +
    theme(axis.title.x = element_blank(),
          axis.text.x = element_blank(),
          axis.ticks.x = element_blank(),
          axis.line = element_line(color = "black", size = 0.1),
          panel.grid = element_blank(),
          panel.border = element_blank(),
          panel.background = element_blank(),
          plot.margin = unit(c(0.03,0.1,0,0.1),"cm")) + coord_cartesian(ylim=c(0,4.35)) + geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=0.65, color="black", fill="white", alpha=0.75)
    
})
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
pp.vln[[6]] <- ggplot(vln_df, aes(x = cnt2, y= get(check.plot[6]), fill = cnt1)) +
    geom_violin(trim = TRUE, scale = 'width', lwd=0.1) +
    labs(x="",y="",title=check.plot[6]) + NoLegend() +
    #scale_fill_manual(values = ggsci::pal_d3("category20c")(20)[c(1,2)]) +
    scale_fill_manual(values = color.test1) +
    theme(axis.title.x = element_blank(),
          #axis.text.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 8.1),
          #axis.ticks.x = element_blank(),
          axis.ticks.x = element_line(color = "black",size=0.05),
          axis.line = element_line(color = "black", size = 0.1),
          panel.grid = element_blank(),
          panel.border = element_blank(),
          panel.background = element_blank(),
          plot.margin = unit(c(0.03,0.1,0,0.1),"cm")) + coord_cartesian(ylim=c(0,4.35)) + geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=0.65, color="black", fill="white", alpha=0.75)
## Warning: `fun.y` is deprecated. Use `fun` instead.
cowplot::plot_grid(
  plotlist = pp.vln,
  ncol = 1,
  rel_heights = c(rep(1,5),1.55))

pp.vln.s <- list()

pp.vln.s <- lapply(1:5, function(jj){
  pp.tmp <- ggplot(vln_df, aes(x = cnt2, y= get(check.plot[jj]), fill = cnt1)) +
    geom_violin(trim = TRUE, scale = 'width', lwd=0.1) +
    labs(x="",y="",title=check.plot[jj]) + NoLegend() +
    #scale_fill_manual(values = ggsci::pal_d3("category20c")(20)[c(1,2)]) +
    scale_fill_manual(values = color.test1) +
    theme(axis.title.x = element_blank(),
          axis.text.x = element_blank(),
          axis.ticks.x = element_blank(),
          axis.line = element_line(color = "black", size = 0.1),
          panel.grid = element_blank(),
          panel.border = element_blank(),
          panel.background = element_blank(),
          plot.margin = unit(c(0.03,0.1,0,0.1),"cm")) + coord_cartesian(ylim=c(0,4.35)) + geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=0.45, color="black", fill="white", alpha=0.75) +
    stat_compare_means(aes(label= ..p.signif..),
                       method = "wilcox.test",
                       comparisons = list.cnt2,
                       label.y = c(rep(3.75,16)),
                       size = 2.5)
    
})
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
pp.vln.s[[6]] <- ggplot(vln_df, aes(x = cnt2, y= get(check.plot[6]), fill = cnt1)) +
    geom_violin(trim = TRUE, scale = 'width', lwd=0.1) +
    labs(x="",y="",title=check.plot[6]) + NoLegend() +
    #scale_fill_manual(values = ggsci::pal_d3("category20c")(20)[c(1,2)]) +
  scale_fill_manual(values = color.test1) +
    theme(axis.title.x = element_blank(),
          #axis.text.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 8.1),
          #axis.ticks.x = element_blank(),
          axis.ticks.x = element_line(color = "black",size=0.05),
          axis.line = element_line(color = "black", size = 0.1),
          panel.grid = element_blank(),
          panel.border = element_blank(),
          panel.background = element_blank(),
          plot.margin = unit(c(0.03,0.1,0,0.1),"cm")) + coord_cartesian(ylim=c(0,4.35)) + geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=0.45, color="black", fill="white", alpha=0.75) +
    stat_compare_means(aes(label= ..p.signif..),
                       method = "wilcox.test",
                       comparisons = list.cnt2,
                       label.y = c(rep(3.75,16)),
                       size = 2.5)
## Warning: `fun.y` is deprecated. Use `fun` instead.
cowplot::plot_grid(
  plotlist = pp.vln.s,
  ncol = 1,
  rel_heights = c(rep(1,5),1.55))

pp.vln.a <- list()

pp.vln.a <- lapply(1:5, function(jj){
  pp.tmp <- ggplot(vln_df, aes(x = intAnno1, y= get(check.plot[jj]), fill = intAnno1)) +
    geom_violin(trim = TRUE, scale = 'width', lwd=0.1) +
    labs(x="",y="",title=check.plot[jj]) + NoLegend() +
    scale_fill_manual(values = color.A1) +
    theme(axis.title.x = element_blank(),
          axis.text.x = element_blank(),
          axis.ticks.x = element_blank(),
          axis.line = element_line(color = "black", size = 0.1),
          panel.grid = element_blank(),
          panel.border = element_blank(),
          panel.background = element_blank(),
          plot.margin = unit(c(0.03,0.1,0,0.1),"cm")) + coord_cartesian(ylim=c(0,4.35)) + geom_boxplot(outlier.size = 0, fill="white", width=0.12, size=0.1) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=0.45, color="black", fill="white", alpha=0.75)
    
})
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
pp.vln.a[[6]] <- ggplot(vln_df, aes(x = intAnno1, y= get(check.plot[6]), fill = intAnno1)) +
    geom_violin(trim = TRUE, scale = 'width', lwd=0.1) +
    labs(x="",y="",title=check.plot[6]) + NoLegend() +
    scale_fill_manual(values = color.A1) +
    theme(axis.title.x = element_blank(),
          #axis.text.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 8.1),
          #axis.ticks.x = element_blank(),
          axis.ticks.x = element_line(color = "black",size=0.05),
          axis.line = element_line(color = "black", size = 0.1),
          panel.grid = element_blank(),
          panel.border = element_blank(),
          panel.background = element_blank(),
          plot.margin = unit(c(0.03,0.1,0,0.1),"cm")) + coord_cartesian(ylim=c(0,4.35)) + geom_boxplot(outlier.size = 0, fill="white", width=0.12, size=0.1) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=0.45, color="black", fill="white", alpha=0.75)
## Warning: `fun.y` is deprecated. Use `fun` instead.
cowplot::plot_grid(
  plotlist = pp.vln.a,
  ncol = 1,
  rel_heights = c(rep(1,5),1.4))

FeaturePlot(test1.seur, features = check.plot, ncol = 3)

FeaturePlot(subset(test1.seur, subset = cnt1 == "PBS"), features = check.plot, ncol = 3)

FeaturePlot(test1.seur, features = check.plot, ncol = 3, pt.size = 1)

FeaturePlot(subset(test1.seur, subset = cnt1 == "PBS"), features = check.plot, ncol = 3, pt.size = 1)

FeaturePlot(test1.seur, features = check.plot, ncol = 3, pt.size = 2)

FeaturePlot(subset(test1.seur, subset = cnt1 == "PBS"), features = check.plot, ncol = 3, pt.size = 2)

DotPlot(test1.seur, features = rev(check.plot), group.by = "cnt2")  + coord_flip() + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 9.6))

DotPlot(test1.seur, features = rev(check.plot), group.by = "cnt2", cols = c("midnightblue","darkorange1"))  + coord_flip() + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1, size = 9.6))

violin

pp.IPAN1 <- list()
pp.IPAN1[["Nmu"]] <- VlnPlot(subset(test1.seur,subset=intAnno1 %in% c("IPAN1")), assay = "RNA", features = c("Nmu"), group.by = "cnt", ncol = 1, cols = color.test1, pt.size = 0.01,
                   combine = T) + 
    geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1, alpha=0.55) +
    stat_summary(fun=mean, geom="point", shape=18, size=3, color="black", alpha=0.55) + coord_cartesian(ylim=c(0,5)) + ggpubr::stat_compare_means(aes(lable = ..p.signif..), 
                               method = "wilcox.test",
                               comparisons = list(c("Nb5d.PBS","Nb5d.INF")),
                               label.y = c(4.35),
                               size=3.5
                               ) + NoLegend()
pp.IPAN1[["Nmu"]]

pp.IPAN1[["Calcb"]] <- VlnPlot(subset(test1.seur,subset=intAnno1 %in% c("IPAN1")), assay = "RNA", features = c("Calcb"), group.by = "cnt", ncol = 1, cols = color.test1, pt.size = 0.01,
                   combine = T) + 
    geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1, alpha=0.55) +
    stat_summary(fun=mean, geom="point", shape=18, size=3, color="black", alpha=0.55) + coord_cartesian(ylim=c(0,5)) + ggpubr::stat_compare_means(aes(lable = ..p.signif..), 
                               method = "wilcox.test",
                               comparisons = list(c("Nb5d.PBS","Nb5d.INF")),
                               label.y = c(4.05),
                               size=3.5
                               ) + NoLegend()
pp.IPAN1[["Calcb"]]

pp.IPAN1[["Calca"]] <- VlnPlot(subset(test1.seur,subset=intAnno1 %in% c("IPAN1")), assay = "RNA", features = c("Calca"), group.by = "cnt", ncol = 1, cols = color.test1, pt.size = 0,
                   combine = T) + 
    #geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1, alpha=0.55) +
  geom_point(size=0.3) +
    stat_summary(fun=mean, geom="point", shape=18, size=3, color="black", alpha=0.55) + coord_cartesian(ylim=c(0,5)) + ggpubr::stat_compare_means(aes(lable = ..p.signif..), 
                               method = "wilcox.test",
                               comparisons = list(c("Nb5d.PBS","Nb5d.INF")),
                               label.y = c(2.15),
                               size=3.5
                               ) + NoLegend()
pp.IPAN1[["Calca"]]

violin-Il13ra1+

ppi.IPAN1 <- list()
test1.seur$Il13ra1p <- test1.seur@assays$RNA@data["Il13ra1",] >0
ppi.IPAN1[["Nmu"]] <- VlnPlot(subset(test1.seur,subset=intAnno1 %in% c("IPAN1") & Il13ra1p==TRUE), assay = "RNA", features = c("Nmu"), group.by = "cnt", ncol = 1, cols = color.test1, pt.size = 0.01,
                   combine = T) + 
    geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1, alpha=0.55) +
    stat_summary(fun=mean, geom="point", shape=18, size=3, color="black", alpha=0.55) + coord_cartesian(ylim=c(0,5)) + ggpubr::stat_compare_means(aes(lable = ..p.signif..), 
                               method = "wilcox.test",
                               comparisons = list(c("Nb5d.PBS","Nb5d.INF")),
                               label.y = c(4.05),
                               size=3.5
                               ) + NoLegend()
ppi.IPAN1[["Nmu"]]

ppi.IPAN1[["Calcb"]] <- VlnPlot(subset(test1.seur,subset=intAnno1 %in% c("IPAN1") & Il13ra1p==TRUE), assay = "RNA", features = c("Calcb"), group.by = "cnt", ncol = 1, cols = color.test1, pt.size = 0.01,
                   combine = T) + 
    geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1, alpha=0.55) +
    stat_summary(fun=mean, geom="point", shape=18, size=3, color="black", alpha=0.55) + coord_cartesian(ylim=c(0,5)) + ggpubr::stat_compare_means(aes(lable = ..p.signif..), 
                               method = "wilcox.test",
                               comparisons = list(c("Nb5d.PBS","Nb5d.INF")),
                               label.y = c(3.6),
                               size=3.5
                               ) + NoLegend()
ppi.IPAN1[["Calcb"]]

ppi.IPAN1[["Calca"]] <- VlnPlot(subset(test1.seur,subset=intAnno1 %in% c("IPAN1") & Il13ra1p==TRUE), assay = "RNA", features = c("Calca"), group.by = "cnt", ncol = 1, cols = color.test1, pt.size = 0,
                   combine = T) + 
    #geom_boxplot(outlier.size = 0, fill="white", width=0.2, size=0.1, alpha=0.55) +
  geom_point(size=0.3) +
    stat_summary(fun=mean, geom="point", shape=18, size=3, color="black", alpha=0.55) + coord_cartesian(ylim=c(0,5)) + ggpubr::stat_compare_means(aes(lable = ..p.signif..), 
                               method = "wilcox.test",
                               comparisons = list(c("Nb5d.PBS","Nb5d.INF")),
                               label.y = c(2.15),
                               size=3.5
                               ) + NoLegend()
ppi.IPAN1[["Calca"]]

check ligand-receptor

using markers in batch PBS_INF
#Idents(test1.seur) <- "intAnno1"

#test1.markers.pre <- FindAllMarkers(test1.seur, only.pos = TRUE, min.pct = 0.05,
#                                  assay = "RNA",
#                                  test.use = "MAST",
#                                  logfc.threshold = 0.25)
#test1.markers.pre <- read.table("Baf53cre_Nb.markers_intAnno1.PBSvsINF.csv", header = TRUE, sep = ",")
#test1.markers.pre %>% group_by(cluster) %>% top_n(n = 8, wt = avg_log2FC)
directly using markers in SCT_intAnno1
markers.new <- read.csv("../integration_Nb5d/Baf53cre_Nb.markers.SCT_intAnno1.202402.csv")
markers.new$cluster <- factor(as.character(markers.new$cluster),
                              levels = levels(GEX.seur$intAnno1))
head(markers.new)
##   p_val avg_log2FC pct.1 pct.2 p_val_adj cluster   gene
## 1     0   1.824018 0.953 0.335         0    EMN1  Ptprt
## 2     0   1.668551 0.981 0.495         0    EMN1  Tshz2
## 3     0   1.585436 0.938 0.319         0    EMN1   Bnc2
## 4     0   1.384775 0.909 0.397         0    EMN1  Grik1
## 5     0   1.301007 1.000 0.793         0    EMN1 Rbfox1
## 6     0   1.107801 0.992 0.864         0    EMN1  Negr1

CellChat

CellChat.secreting <- list(ligand=as.vector(unlist(read.table("./figures.integration/PBSvsINF.replot/Markers/CellChat.list/CellChat.interaction.secreting.ligand_all.txt"))),
                           receptor=as.vector(unlist(read.table("./figures.integration/PBSvsINF.replot/Markers/CellChat.list/CellChat.interaction.secreting.receptor_all.txt"))))
lapply(CellChat.secreting,length)
## $ligand
## [1] 364
## 
## $receptor
## [1] 328
lapply(CellChat.secreting,head)
## $ligand
## [1] "Tgfb1" "Tgfb2" "Tgfb3" "Bmp2"  "Bmp4"  "Gdf5" 
## 
## $receptor
## [1] "Tgfbr1" "Tgfbr2" "Acvr1b" "Acvr1c" "Acvr1"  "Bmpr1a"

markers

# sort all ligand genes in significant markers
markers.new_ligand.pct_0.15.padj_0.001 <- (markers.new %>% group_by(cluster) %>% 
                       filter(pct.1>0.15 & p_val_adj < 0.001 & gene %in% CellChat.secreting$ligand) %>%
                       #top_n(n = 48, wt = avg_log2FC) %>%
                       ungroup() %>%
                       arrange(desc(avg_log2FC*pct.1),gene) %>%
                       distinct(gene, .keep_all = TRUE) %>%
                       arrange(cluster,p_val_adj)) %>% as.data.frame()

# sort all receptor genes in significant markers
markers.new_receptor.pct_0.15.padj_0.001 <- (markers.new %>% group_by(cluster) %>% 
                       filter(pct.1>0.15 & p_val_adj < 0.001 & gene %in% CellChat.secreting$receptor) %>%
                       #top_n(n = 48, wt = avg_log2FC) %>%
                       ungroup() %>%
                       arrange(desc(avg_log2FC*pct.1),gene) %>%
                       distinct(gene, .keep_all = TRUE) %>%
                       arrange(cluster,p_val_adj)) %>% as.data.frame()
dim(markers.new_ligand.pct_0.15.padj_0.001)[1]
## [1] 25
dim(markers.new_receptor.pct_0.15.padj_0.001)[1]
## [1] 63
markers.new_ligand.pct_0.15.padj_0.001
##            p_val avg_log2FC pct.1 pct.2     p_val_adj cluster   gene
## 1   0.000000e+00  1.1076947 1.000 0.930  0.000000e+00    EMN1   Nrg3
## 2  6.065518e-184  0.5636193 0.549 0.228 1.239428e-179    EMN3    Eda
## 3   3.827394e-13  0.1322432 0.343 0.275  7.820898e-09    EMN3   Psap
## 4   9.105471e-59  0.5506514 0.526 0.153  1.860612e-54    EMN4    Hgf
## 5  4.624466e-275  1.5727641 0.858 0.250 9.449635e-271    EMN5   Tac1
## 6  1.827560e-252  1.1479185 0.626 0.047 3.734436e-248    EMN5   Penk
## 7  4.088367e-130  0.6924884 0.371 0.029 8.354170e-126    EMN5 Sema3e
## 8   3.521177e-45  0.4604326 0.478 0.164  7.195173e-41    EMN5    Ptn
## 9   0.000000e+00  0.5626011 0.389 0.073  0.000000e+00    IMN1   Kitl
## 10 6.181438e-279  1.2947562 0.751 0.133 1.263115e-274    IMN3    Vip
## 11  1.980605e-42  0.2330640 0.161 0.020  4.047167e-38    IMN3 Angpt1
## 12  4.458289e-42  0.3509201 0.406 0.148  9.110068e-38    IMN3   Gas6
## 13  5.582472e-16  0.1704251 0.435 0.266  1.140722e-11    IMN3   Fgf1
## 14  3.641857e-76  0.2957764 0.197 0.005  7.441771e-72    IMN4   Pdyn
## 15  2.671636e-47  0.3880091 0.255 0.035  5.459222e-43    IMN4    Grp
## 16  0.000000e+00  2.2246127 0.988 0.440  0.000000e+00     IN1   Nrg1
## 17  0.000000e+00  2.0988727 0.885 0.257  0.000000e+00     IN1    Gal
## 18 3.865699e-119  1.4448321 0.650 0.015 7.899170e-115     IN3    Sst
## 19  0.000000e+00  2.1177143 0.703 0.104  0.000000e+00   IPAN1    Nmu
## 20  0.000000e+00  1.1291159 0.658 0.080  0.000000e+00   IPAN1  Calcb
## 21 6.754990e-293  0.3905187 0.283 0.018 1.380315e-288   IPAN1    Il7
## 22 2.085811e-218  0.2727499 0.206 0.011 4.262146e-214   IPAN1   Bmp4
## 23  1.693378e-87  0.3077026 0.384 0.161  3.460248e-83   IPAN1   Nrg2
## 24  2.830143e-10  0.2201720 0.192 0.034  5.783115e-06   IPAN3 Sema3c
## 25  7.195690e-44  0.3025856 0.279 0.078  1.470367e-39   IPAN4  Vegfa
markers.new_receptor.pct_0.15.padj_0.001
##            p_val avg_log2FC pct.1 pct.2     p_val_adj cluster      gene
## 1   0.000000e+00  0.5207381 0.483 0.202  0.000000e+00    EMN1    Chrna7
## 2   0.000000e+00  0.4537600 0.360 0.093  0.000000e+00    EMN1     Oprk1
## 3  1.217599e-137  0.2181927 0.222 0.087 2.488041e-133    EMN1     Itga6
## 4  5.993268e-118  0.2926601 0.782 0.715 1.224664e-113    EMN1     Fgfr2
## 5   1.025052e-82  0.2338149 0.219 0.067  2.094592e-78    EMN3    Agtr1a
## 6  1.424846e-193  1.0748133 0.710 0.107 2.911530e-189    EMN4     Ntrk2
## 7  1.309460e-196  0.6894317 0.449 0.012 2.675751e-192    EMN5      Egfr
## 8  1.299446e-133  0.9245781 0.753 0.192 2.655289e-129    EMN5    Ptprz1
## 9  1.479486e-104  0.8215978 0.788 0.298 3.023181e-100    EMN5      Nrp2
## 10 6.782722e-208  0.3996465 0.423 0.192 1.385981e-203    IMN1     Igf2r
## 11 7.483520e-171  0.3270215 0.354 0.154 1.529182e-166    IMN1     Oprd1
## 12 6.710387e-174  0.9432587 0.813 0.220 1.371200e-169    IMN3     Gfra1
## 13  1.446881e-55  0.4236405 0.457 0.153  2.956557e-51    IMN3     Itga8
## 14  5.183468e-55  0.3684805 0.324 0.080  1.059190e-50    IMN3    Bdkrb2
## 15  7.268367e-51  0.2674485 0.213 0.032  1.485218e-46    IMN3     Npy2r
## 16  3.556710e-43  0.2414330 0.195 0.033  7.267780e-39    IMN3       F2r
## 17  2.409844e-33  0.2503877 0.266 0.079  4.924274e-29    IMN3     Tyro3
## 18  2.886256e-21  0.2248048 0.292 0.126  5.897776e-17    IMN3      Fzd3
## 19  5.592817e-13  0.1451864 0.352 0.213  1.142836e-08    IMN3    Chrna3
## 20  4.568093e-12  0.2013487 0.416 0.266  9.334442e-08    IMN3      Insr
## 21  5.477034e-12  0.1614192 0.308 0.175  1.119177e-07    IMN3 Adcyap1r1
## 22  3.132961e-08  0.1036473 0.163 0.082  6.401893e-04    IMN3      Sdc2
## 23  6.066951e-51  0.2319856 0.173 0.008  1.239721e-46    IMN4     Tacr3
## 24  2.583724e-08  0.1577374 0.242 0.123  5.279583e-04    IMN4    Chrnb4
## 25 2.601934e-188  0.9101337 0.729 0.258 5.316792e-184     IN1     Cdh11
## 26  1.869240e-30  0.2308660 0.285 0.113  3.819605e-26     IN1     Sort1
## 27  1.875902e-24  0.1618972 0.155 0.045  3.833219e-20     IN1     Ednrb
## 28 4.318443e-155  0.5486427 0.374 0.011 8.824307e-151     IN2      Sctr
## 29  9.501281e-79  0.2848264 0.212 0.008  1.941492e-74     IN2     Ntsr1
## 30  1.019314e-70  0.4843119 0.382 0.064  2.082867e-66     IN2      Nrp1
## 31  1.260777e-19  0.3588583 0.272 0.027  2.576272e-15     IN3     Vipr2
## 32  5.864233e-16  0.5714126 0.553 0.201  1.198297e-11     IN3     Gfra2
## 33  2.349976e-13  0.2554309 0.175 0.015  4.801941e-09     IN3     Tacr1
## 34  0.000000e+00  2.3298186 0.989 0.187  0.000000e+00   IPAN1     Ntrk3
## 35  0.000000e+00  1.7609063 0.946 0.204  0.000000e+00   IPAN1    Plxna4
## 36  0.000000e+00  1.1113411 0.590 0.009  0.000000e+00   IPAN1     Itgb6
## 37  0.000000e+00  0.7768492 0.553 0.044  0.000000e+00   IPAN1     Galr1
## 38  0.000000e+00  0.6517939 0.486 0.096  0.000000e+00   IPAN1      Ngfr
## 39  0.000000e+00  0.5432981 0.373 0.020  0.000000e+00   IPAN1       Met
## 40 4.699070e-282  0.7838060 0.834 0.547 9.602079e-278   IPAN1     Igf1r
## 41 2.664584e-189  0.5616217 0.554 0.199 5.444812e-185   IPAN1    Calcrl
## 42 1.052026e-186  0.4668295 0.481 0.164 2.149710e-182   IPAN1      Npr2
## 43 1.563327e-160  0.2500400 0.197 0.020 3.194502e-156   IPAN1      Gcgr
## 44  8.811416e-97  0.2263668 0.199 0.041  1.800525e-92   IPAN1   Il13ra1
## 45  2.064858e-59  0.1627802 0.162 0.044  4.219330e-55   IPAN1     Cntfr
## 46  1.329464e-52  0.2785298 0.393 0.213  2.716626e-48   IPAN1    Plxna2
## 47  1.907800e-41  0.2002669 0.356 0.198  3.898399e-37   IPAN1    Bmpr1a
## 48  7.062835e-31  0.1257900 0.168 0.073  1.443220e-26   IPAN1    Plxna3
## 49  1.271821e-26  0.1611509 0.311 0.188  2.598840e-22   IPAN1     Itgb1
## 50  5.474453e-26  0.1285295 0.208 0.108  1.118650e-21   IPAN1     Acvr1
## 51  9.130241e-24  0.1838976 0.434 0.309  1.865673e-19   IPAN1     Bmpr2
## 52  1.213296e-16  0.1025542 0.212 0.130  2.479249e-12   IPAN1      Lrp6
## 53  0.000000e+00  1.2980715 0.990 0.654  0.000000e+00   IPAN2       Alk
## 54 3.557226e-233  0.3622293 0.252 0.012 7.268835e-229   IPAN2     Nmur2
## 55 7.634807e-194  0.7217496 0.385 0.087 1.560096e-189   IPAN2       Ghr
## 56  1.622181e-27  0.7533781 0.642 0.259  3.314765e-23   IPAN3     Oprm1
## 57  0.000000e+00  1.1795053 0.629 0.014  0.000000e+00   IPAN4    Bmpr1b
## 58  2.367353e-88  0.2369190 0.157 0.003  4.837450e-84   IPAN4     Npy5r
## 59  6.581974e-72  0.2937324 0.191 0.015  1.344960e-67   IPAN4     Cckar
## 60  1.043326e-67  0.2705104 0.181 0.014  2.131933e-63   IPAN4     Glp1r
## 61  1.590873e-63  0.3124106 0.230 0.036  3.250790e-59   IPAN4     Npy1r
## 62  1.283549e-21  0.2569076 0.318 0.151  2.622804e-17   IPAN4     Fgfr1
## 63  2.412892e-16  0.2543119 0.507 0.332  4.930503e-12   IPAN4     Pard3

PBSvsINF

DotPlot(test1.seur, features = markers.new_ligand.pct_0.15.padj_0.001$gene, group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10.15))+ scale_y_discrete(limits=rev) + labs(title="ligand.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

DotPlot(test1.seur, features = markers.new_receptor.pct_0.15.padj_0.001$gene, group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10))+ scale_y_discrete(limits=rev) + labs(title="receptor.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

NatNeur2021

DotPlot(ref.seur, features = markers.new_ligand.pct_0.15.padj_0.001$gene, group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10.15))+ scale_y_discrete(limits=rev) + labs(title="ligand.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

DotPlot(ref.seur, features = markers.new_receptor.pct_0.15.padj_0.001$gene, group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10))+ scale_y_discrete(limits=rev) + labs(title="receptor.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

CellTalkDB

mat.lr <- read.table("figures.integration/PBSvsINF.replot/Markers/CellTalkDB.list/CellTalkDB.20230203.mouse_lr_pair.txt", header = T)
head(mat.lr)
##     lr_pair ligand_gene_symbol receptor_gene_symbol ligand_gene_id
## 1 Wnt3_Fzd6               Wnt3                 Fzd6          22415
## 2 Wnt3_Egfr               Wnt3                 Egfr          22415
## 3 Wnt3_Fzd2               Wnt3                 Fzd2          22415
## 4 Wnt3_Lrp5               Wnt3                 Lrp5          22415
## 5 Wnt3_Fzd1               Wnt3                 Fzd1          22415
## 6 Wnt3_Fzd3               Wnt3                 Fzd3          22415
##   receptor_gene_id ligand_ensembl_protein_id receptor_ensembl_protein_id
## 1            14368        ENSMUSP00000000127          ENSMUSP00000022906
## 2            13649        ENSMUSP00000000127          ENSMUSP00000020329
## 3            57265        ENSMUSP00000000127          ENSMUSP00000091463
## 4            16973        ENSMUSP00000000127          ENSMUSP00000025856
## 5            14362        ENSMUSP00000000127          ENSMUSP00000058629
## 6            14365        ENSMUSP00000000127          ENSMUSP00000115325
##   ligand_ensembl_gene_id receptor_ensembl_gene_id evidence
## 1     ENSMUSG00000000125       ENSMUSG00000022297 19901330
## 2     ENSMUSG00000000125       ENSMUSG00000020122 17374561
## 3     ENSMUSG00000000125       ENSMUSG00000050288 31907106
## 4     ENSMUSG00000000125       ENSMUSG00000024913 11719191
## 5     ENSMUSG00000000125       ENSMUSG00000044674 20667980
## 6     ENSMUSG00000000125       ENSMUSG00000007989 18212053
length(unique(mat.lr$ligand_gene_symbol))
## [1] 651
length(unique(mat.lr$receptor_gene_symbol))
## [1] 588

markers

# sort all ligand genes in significant markers
markers.new_ligand.pct_0.15.padj_0.001 <- (markers.new %>% group_by(cluster) %>% 
                       filter(pct.1>0.15 & p_val_adj < 0.001 & gene %in% unique(mat.lr$ligand_gene_symbol)) %>%
                       #top_n(n = 48, wt = avg_log2FC) %>%
                       ungroup() %>%
                       arrange(desc(avg_log2FC*pct.1),gene) %>%
                       distinct(gene, .keep_all = TRUE) %>%
                       arrange(cluster,p_val_adj)) %>% as.data.frame()

# sort all receptor genes in significant markers
markers.new_receptor.pct_0.15.padj_0.001 <- (markers.new %>% group_by(cluster) %>% 
                       filter(pct.1>0.15 & p_val_adj < 0.001 & gene %in% unique(mat.lr$receptor_gene_symbol)) %>%
                       #top_n(n = 48, wt = avg_log2FC) %>%
                       ungroup() %>%
                       arrange(desc(avg_log2FC*pct.1),gene) %>%
                       distinct(gene, .keep_all = TRUE) %>%
                       arrange(cluster,p_val_adj)) %>% as.data.frame()
dim(markers.new_ligand.pct_0.15.padj_0.001)[1]
## [1] 89
dim(markers.new_receptor.pct_0.15.padj_0.001)[1]
## [1] 134
markers.new_ligand.pct_0.15.padj_0.001
##            p_val avg_log2FC pct.1 pct.2     p_val_adj cluster     gene
## 1   0.000000e+00  1.1076947 1.000 0.930  0.000000e+00    EMN1     Nrg3
## 2   0.000000e+00  0.7232543 0.822 0.558  0.000000e+00    EMN1    Dscam
## 3   0.000000e+00  0.5769797 0.926 0.766  0.000000e+00    EMN1   Sema6d
## 4  4.695799e-256  0.5021931 0.427 0.218 9.595396e-252    EMN1    Rspo2
## 5   4.627980e-92  0.2517767 0.511 0.387  9.456815e-88    EMN1     Rgmb
## 6  1.405155e-138  0.3616922 0.366 0.117 2.871293e-134    EMN2     Colq
## 7  1.123065e-108  0.2768502 0.324 0.110 2.294870e-104    EMN2    Slit1
## 8   0.000000e+00  0.8797513 0.494 0.046  0.000000e+00    EMN3    Nxph1
## 9  6.065518e-184  0.5636193 0.549 0.228 1.239428e-179    EMN3      Eda
## 10  3.827394e-13  0.1322432 0.343 0.275  7.820898e-09    EMN3     Psap
## 11  2.501708e-68  0.4546573 0.267 0.021  5.111989e-64    EMN4    Lama2
## 12  9.105471e-59  0.5506514 0.526 0.153  1.860612e-54    EMN4      Hgf
## 13  6.111817e-42  0.2823764 0.224 0.030  1.248889e-37    EMN4    Efnb2
## 14  4.138119e-39  0.4284888 0.511 0.198  8.455832e-35    EMN4    Cd200
## 15  5.410714e-10  0.1619891 0.205 0.090  1.105625e-05    EMN4      Vcl
## 16 4.624466e-275  1.5727641 0.858 0.250 9.449635e-271    EMN5     Tac1
## 17 4.088367e-130  0.6924884 0.371 0.029 8.354170e-126    EMN5   Sema3e
## 18 2.388526e-117  0.4307895 0.288 0.009 4.880715e-113    EMN5     Ntn1
## 19  3.521177e-45  0.4604326 0.478 0.164  7.195173e-41    EMN5      Ptn
## 20  9.423596e-18  0.3282928 0.898 0.778  1.925618e-13    EMN5    Ncam1
## 21  1.089338e-13  0.2299454 0.315 0.155  2.225954e-09    EMN5     Agrp
## 22  1.000216e-08  0.1727080 0.272 0.151  2.043841e-04    EMN5     Jam3
## 23  1.205417e-08  0.2263650 0.435 0.296  2.463149e-04    EMN5    Calm1
## 24  1.611949e-08  0.1669165 0.306 0.177  3.293856e-04    EMN5    Gng12
## 25  0.000000e+00  0.5626011 0.389 0.073  0.000000e+00    IMN1     Kitl
## 26 1.411700e-171  0.3816347 0.473 0.254 2.884667e-167    IMN1    Spon1
## 27  1.675348e-71  0.2812034 0.552 0.424  3.423406e-67    IMN1    Slit3
## 28 6.181438e-279  1.2947562 0.751 0.133 1.263115e-274    IMN3      Vip
## 29  1.251052e-88  0.7199983 0.948 0.636  2.556400e-84    IMN3    Slit2
## 30  1.980605e-42  0.2330640 0.161 0.020  4.047167e-38    IMN3   Angpt1
## 31  4.458289e-42  0.3509201 0.406 0.148  9.110068e-38    IMN3     Gas6
## 32  5.525018e-24  0.2773511 0.404 0.200  1.128982e-19    IMN3     Dkk3
## 33  1.438444e-18  0.2566154 0.539 0.340  2.939316e-14    IMN3     Afdn
## 34  1.495309e-17  0.1574750 0.175 0.060  3.055514e-13    IMN3  Adamts3
## 35  9.323012e-17  0.2009966 0.408 0.233  1.905064e-12    IMN3   Sema4d
## 36  5.582472e-16  0.1704251 0.435 0.266  1.140722e-11    IMN3     Fgf1
## 37  1.597041e-89  0.6218592 0.455 0.060  3.263393e-85    IMN4   Adam12
## 38  3.567328e-76  0.4609484 0.388 0.049  7.289479e-72    IMN4    Lama4
## 39  3.641857e-76  0.2957764 0.197 0.005  7.441771e-72    IMN4     Pdyn
## 40  3.442470e-63  0.4258319 0.315 0.037  7.034344e-59    IMN4   Igfbp5
## 41  2.790880e-52  0.5376480 0.473 0.144  5.702884e-48    IMN4   Sema6a
## 42  2.671636e-47  0.3880091 0.255 0.035  5.459222e-43    IMN4      Grp
## 43  6.849351e-19  0.2384707 0.294 0.108  1.399596e-14    IMN4  St6gal1
## 44  1.062254e-14  0.1768879 0.170 0.048  2.170610e-10    IMN4    Rspo3
## 45  7.036385e-14  0.2682218 0.442 0.251  1.437815e-09    IMN4      Fyn
## 46  0.000000e+00  2.2246127 0.988 0.440  0.000000e+00     IN1     Nrg1
## 47  0.000000e+00  2.0988727 0.885 0.257  0.000000e+00     IN1      Gal
## 48  0.000000e+00  1.1638942 0.891 0.415  0.000000e+00     IN1    Fgf12
## 49  0.000000e+00  0.8357698 0.546 0.030  0.000000e+00     IN1  Col18a1
## 50  4.418156e-72  0.2408625 0.178 0.016  9.028059e-68     IN1    Cntn6
## 51 2.022553e-237  1.2472501 0.973 0.665 4.132884e-233     IN2    Efna5
## 52  1.940703e-76  0.5556081 0.517 0.130  3.965633e-72     IN2   Col4a2
## 53  2.074089e-68  0.4670462 0.401 0.082  4.238193e-64     IN2   Col4a1
## 54  1.132337e-09  0.1459152 0.233 0.115  2.313817e-05     IN2   Shank3
## 55 3.865699e-119  1.4448321 0.650 0.015 7.899170e-115     IN3      Sst
## 56  3.504370e-24  0.8038992 1.000 0.955  7.160830e-20     IN3    Nlgn1
## 57  5.170864e-10  0.2690654 0.243 0.051  1.056614e-05     IN3     Fat4
## 58  0.000000e+00  1.7350722 0.997 0.915  0.000000e+00   IPAN1    Fgf14
## 59  0.000000e+00  2.1177143 0.703 0.104  0.000000e+00   IPAN1      Nmu
## 60  0.000000e+00  1.1522530 0.821 0.170  0.000000e+00   IPAN1     Agrn
## 61  0.000000e+00  0.9299479 0.997 0.983  0.000000e+00   IPAN1    Fgf13
## 62 6.754990e-293  0.3905187 0.283 0.018 1.380315e-288   IPAN1      Il7
## 63 2.085811e-218  0.2727499 0.206 0.011 4.262146e-214   IPAN1     Bmp4
## 64 9.166759e-139  0.2058529 0.152 0.012 1.873136e-134   IPAN1      Vwf
## 65  6.484031e-95  0.4675030 0.785 0.668  1.324947e-90   IPAN1      App
## 66  2.852418e-90  0.3352033 0.426 0.203  5.828632e-86   IPAN1   Adam10
## 67  1.693378e-87  0.3077026 0.384 0.161  3.460248e-83   IPAN1     Nrg2
## 68  1.248249e-77  0.3125672 0.430 0.214  2.550673e-73   IPAN1     Gnb4
## 69  2.666037e-72  0.2014929 0.199 0.056  5.447781e-68   IPAN1    Anxa2
## 70  8.034726e-62  0.3295213 0.624 0.429  1.641816e-57   IPAN1     Gnas
## 71  3.786718e-46  0.1617267 0.185 0.067  7.737779e-42   IPAN1  S100a10
## 72  7.160418e-43  0.2623354 0.627 0.455  1.463160e-38   IPAN1     Rtn4
## 73  7.947266e-39  0.2092312 0.397 0.237  1.623944e-34   IPAN1    L1cam
## 74  2.048710e-30  0.2057777 0.315 0.195  4.186334e-26   IPAN1 Hsp90aa1
## 75  7.202046e-22  0.1161035 0.234 0.138  1.471666e-17   IPAN1    Hmgb1
## 76  1.318258e-20  0.1373151 0.285 0.180  2.693728e-16   IPAN1    Hspa8
## 77  9.104585e-19  0.1045110 0.194 0.111  1.860431e-14   IPAN1   Lgals8
## 78  0.000000e+00  1.4905029 0.761 0.025  0.000000e+00   IPAN2   Sema5a
## 79 3.849160e-280  0.7507954 0.523 0.108 7.865373e-276   IPAN2     Vcan
## 80 1.610701e-244  0.5654185 0.400 0.058 3.291307e-240   IPAN2 Serpine2
## 81 1.806332e-139  1.6640545 0.942 0.367 3.691058e-135   IPAN3     Gng2
## 82  5.388104e-19  0.4219427 0.192 0.015  1.101005e-14   IPAN3   Col8a1
## 83  8.395130e-14  0.2982836 0.217 0.040  1.715461e-09   IPAN3    Lrig1
## 84  7.181188e-13  0.2061423 0.167 0.018  1.467404e-08   IPAN3    Lamb1
## 85  2.830143e-10  0.2201720 0.192 0.034  5.783115e-06   IPAN3   Sema3c
## 86  0.000000e+00  2.7296055 0.980 0.119  0.000000e+00   IPAN4    Ntng1
## 87  0.000000e+00  1.4326698 0.703 0.004  0.000000e+00   IPAN4    Nxph2
## 88  3.700578e-49  0.3581029 0.324 0.105  7.561762e-45   IPAN4    Cd24a
## 89  7.195690e-44  0.3025856 0.279 0.078  1.470367e-39   IPAN4    Vegfa
markers.new_receptor.pct_0.15.padj_0.001
##             p_val avg_log2FC pct.1 pct.2     p_val_adj cluster      gene
## 1    0.000000e+00  0.5696470 0.758 0.502  0.000000e+00    EMN1      Ryr2
## 2    0.000000e+00  0.5207381 0.483 0.202  0.000000e+00    EMN1    Chrna7
## 3    0.000000e+00  0.4537600 0.360 0.093  0.000000e+00    EMN1     Oprk1
## 4   2.034240e-271  0.3136114 0.273 0.075 4.156767e-267    EMN1     Epha4
## 5   1.217599e-137  0.2181927 0.222 0.087 2.488041e-133    EMN1     Itga6
## 6   5.993268e-118  0.2926601 0.782 0.715 1.224664e-113    EMN1     Fgfr2
## 7   1.493752e-116  0.2386946 0.304 0.167 3.052332e-112    EMN1     Ephb2
## 8   1.429515e-211  0.5893812 0.973 0.745 2.921071e-207    EMN2     Epha6
## 9    5.527483e-66  0.1938802 0.212 0.072  1.129486e-61    EMN2      Ddr2
## 10   2.272633e-38  0.1892803 0.425 0.270  4.643898e-34    EMN2     Nrxn2
## 11   3.528621e-31  0.1790129 0.357 0.226  7.210384e-27    EMN2      Cd47
## 12   8.178191e-31  0.1372952 0.226 0.120  1.671132e-26    EMN2      Lgr4
## 13   8.390408e-22  0.1064386 0.617 0.499  1.714496e-17    EMN2     Lrrc4
## 14   0.000000e+00  1.3845582 0.894 0.286  0.000000e+00    EMN3    Sorcs1
## 15   0.000000e+00  1.0376244 0.918 0.541  0.000000e+00    EMN3     Lrp1b
## 16   1.025052e-82  0.2338149 0.219 0.067  2.094592e-78    EMN3    Agtr1a
## 17  1.424846e-193  1.0748133 0.710 0.107 2.911530e-189    EMN4     Ntrk2
## 18   1.429339e-59  0.3416694 0.264 0.027  2.920711e-55    EMN4     Itgb8
## 19   0.000000e+00  2.3913595 1.000 0.860  0.000000e+00    EMN5      Grm7
## 20   0.000000e+00  2.3653729 0.962 0.194  0.000000e+00    EMN5     Unc5d
## 21  1.309460e-196  0.6894317 0.449 0.012 2.675751e-192    EMN5      Egfr
## 22  1.299446e-133  0.9245781 0.753 0.192 2.655289e-129    EMN5    Ptprz1
## 23  1.479486e-104  0.8215978 0.788 0.298 3.023181e-100    EMN5      Nrp2
## 24   2.221920e-89  0.8346445 1.000 0.876  4.540272e-85    EMN5     Kcnq3
## 25   5.912632e-27  0.2898816 0.325 0.110  1.208187e-22    EMN5     Kcnj6
## 26   0.000000e+00  1.2098622 0.977 0.584  0.000000e+00    IMN1     Epha5
## 27  6.782722e-208  0.3996465 0.423 0.192 1.385981e-203    IMN1     Igf2r
## 28  7.483520e-171  0.3270215 0.354 0.154 1.529182e-166    IMN1     Oprd1
## 29   3.633610e-53  0.2895996 0.297 0.111  7.424918e-49    IMN2     Htr2c
## 30   4.599470e-28  0.2164714 0.427 0.260  9.398557e-24    IMN2      Cdon
## 31  2.637889e-272  1.4455445 0.990 0.552 5.390262e-268    IMN3     Alcam
## 32  3.983898e-180  1.2349436 0.966 0.583 8.140696e-176    IMN3    Lrrc4c
## 33  6.710387e-174  0.9432587 0.813 0.220 1.371200e-169    IMN3     Gfra1
## 34  2.782201e-166  0.6135130 0.412 0.029 5.685150e-162    IMN3    Sorcs2
## 35  2.584663e-131  0.7508023 0.557 0.116 5.281500e-127    IMN3    Sorcs3
## 36   6.686611e-77  0.6382527 0.881 0.586  1.366342e-72    IMN3   Cacna1c
## 37   1.446881e-55  0.4236405 0.457 0.153  2.956557e-51    IMN3     Itga8
## 38   2.434740e-52  0.4313000 0.586 0.260  4.975147e-48    IMN3       Ret
## 39   7.268367e-51  0.2674485 0.213 0.032  1.485218e-46    IMN3     Npy2r
## 40   2.409844e-33  0.2503877 0.266 0.079  4.924274e-29    IMN3     Tyro3
## 41   1.097179e-31  0.2214288 0.211 0.053  2.241976e-27    IMN3      Thy1
## 42   2.668710e-29  0.3000703 0.590 0.334  5.453242e-25    IMN3     Ptprj
## 43   1.395181e-21  0.2537882 0.421 0.221  2.850912e-17    IMN3    Plxnb1
## 44   2.886256e-21  0.2248048 0.292 0.126  5.897776e-17    IMN3      Fzd3
## 45   4.568093e-12  0.2013487 0.416 0.266  9.334442e-08    IMN3      Insr
## 46   5.477034e-12  0.1614192 0.308 0.175  1.119177e-07    IMN3 Adcyap1r1
## 47   3.132961e-08  0.1036473 0.163 0.082  6.401893e-04    IMN3      Sdc2
## 48   4.357805e-08  0.1033503 0.173 0.091  8.904738e-04    IMN3    Scarb1
## 49   2.742455e-98  0.8506552 0.997 0.887  5.603933e-94    IMN4     Cadm1
## 50   2.109198e-59  0.3971040 0.285 0.032  4.309936e-55    IMN4     Adcy8
## 51   6.066951e-51  0.2319856 0.173 0.008  1.239721e-46    IMN4     Tacr3
## 52   1.731136e-22  0.2449520 0.252 0.072  3.537402e-18    IMN4    Notch2
## 53  9.300447e-147  0.6288793 0.433 0.078 1.900453e-142     IN1     Epha8
## 54   1.869240e-30  0.2308660 0.285 0.113  3.819605e-26     IN1     Sort1
## 55   1.875902e-24  0.1618972 0.155 0.045  3.833219e-20     IN1     Ednrb
## 56   2.135338e-08  0.1248383 0.211 0.127  4.363350e-04     IN1    Tgfbr3
## 57   0.000000e+00  2.4042144 1.000 0.832  0.000000e+00     IN2     Kcnd2
## 58  4.012357e-163  0.9049220 0.642 0.105 8.198850e-159     IN2     Ptprm
## 59  4.318443e-155  0.5486427 0.374 0.011 8.824307e-151     IN2      Sctr
## 60   4.180491e-86  0.6461999 1.000 0.987  8.542415e-82     IN2     Nrxn1
## 61   9.501281e-79  0.2848264 0.212 0.008  1.941492e-74     IN2     Ntsr1
## 62   3.684699e-71  0.4492332 0.361 0.055  7.529314e-67     IN2   Rtn4rl1
## 63   1.019314e-70  0.4843119 0.382 0.064  2.082867e-66     IN2      Nrp1
## 64   2.378602e-58  0.3282018 0.249 0.027  4.860434e-54     IN2    Lingo1
## 65   5.694484e-18  0.2806563 0.456 0.244  1.163611e-13     IN2    Plscr4
## 66   2.873623e-13  0.2769928 0.711 0.529  5.871961e-09     IN2     Cntn1
## 67  4.242823e-243  2.6705191 1.000 0.361 8.669785e-239     IN3     Robo1
## 68   1.762096e-30  0.6008290 0.427 0.068  3.600666e-26     IN3     Nrcam
## 69   1.260777e-19  0.3588583 0.272 0.027  2.576272e-15     IN3     Vipr2
## 70   5.864233e-16  0.5714126 0.553 0.201  1.198297e-11     IN3     Gfra2
## 71   2.349976e-13  0.2554309 0.175 0.015  4.801941e-09     IN3     Tacr1
## 72   0.000000e+00  2.8285442 0.999 0.412  0.000000e+00   IPAN1     Nrxn3
## 73   0.000000e+00  2.4257390 0.976 0.202  0.000000e+00   IPAN1     Robo2
## 74   0.000000e+00  2.3298186 0.989 0.187  0.000000e+00   IPAN1     Ntrk3
## 75   0.000000e+00  1.7609063 0.946 0.204  0.000000e+00   IPAN1    Plxna4
## 76   0.000000e+00  1.7063221 0.916 0.156  0.000000e+00   IPAN1     Ccbe1
## 77   0.000000e+00  0.8990972 0.777 0.326  0.000000e+00   IPAN1      Cnr1
## 78   0.000000e+00  1.1113411 0.590 0.009  0.000000e+00   IPAN1     Itgb6
## 79   0.000000e+00  0.7768492 0.553 0.044  0.000000e+00   IPAN1     Galr1
## 80   0.000000e+00  0.6517939 0.486 0.096  0.000000e+00   IPAN1      Ngfr
## 81   0.000000e+00  0.5432981 0.373 0.020  0.000000e+00   IPAN1       Met
## 82  4.699070e-282  0.7838060 0.834 0.547 9.602079e-278   IPAN1     Igf1r
## 83  1.950625e-191  0.5055353 0.401 0.120 3.985907e-187   IPAN1      Dysf
## 84  2.664584e-189  0.5616217 0.554 0.199 5.444812e-185   IPAN1    Calcrl
## 85  8.785513e-189  0.3792247 0.309 0.052 1.795232e-184   IPAN1    Ptger3
## 86  1.052026e-186  0.4668295 0.481 0.164 2.149710e-182   IPAN1      Npr2
## 87  1.563327e-160  0.2500400 0.197 0.020 3.194502e-156   IPAN1      Gcgr
## 88  7.165252e-122  0.2060210 0.161 0.018 1.464148e-117   IPAN1     Itga2
## 89  5.557332e-119  0.2072282 0.172 0.022 1.135585e-114   IPAN1     Unc5b
## 90  1.507779e-112  0.4181966 0.611 0.329 3.080996e-108   IPAN1     Scn5a
## 91   8.811416e-97  0.2263668 0.199 0.041  1.800525e-92   IPAN1   Il13ra1
## 92   4.741757e-86  0.3659477 0.514 0.284  9.689307e-82   IPAN1       Cd9
## 93   5.826719e-67  0.3080774 0.545 0.324  1.190632e-62   IPAN1     Ptprs
## 94   2.064858e-59  0.1627802 0.162 0.044  4.219330e-55   IPAN1     Cntfr
## 95   7.680874e-58  0.2348555 0.284 0.124  1.569510e-53   IPAN1      Cd81
## 96   1.329464e-52  0.2785298 0.393 0.213  2.716626e-48   IPAN1    Plxna2
## 97   2.490239e-47  0.2101567 0.311 0.153  5.088554e-43   IPAN1    Ptger4
## 98   1.907800e-41  0.2002669 0.356 0.198  3.898399e-37   IPAN1    Bmpr1a
## 99   1.478166e-37  0.2257388 0.403 0.250  3.020485e-33   IPAN1     Aplp2
## 100  7.062835e-31  0.1257900 0.168 0.073  1.443220e-26   IPAN1    Plxna3
## 101  2.806665e-29  0.1540963 0.268 0.148  5.735139e-25   IPAN1   Tspan17
## 102  3.211133e-29  0.1894583 0.404 0.263  6.561629e-25   IPAN1     Trpc6
## 103  1.271821e-26  0.1611509 0.311 0.188  2.598840e-22   IPAN1     Itgb1
## 104  5.474453e-26  0.1285295 0.208 0.108  1.118650e-21   IPAN1     Acvr1
## 105  9.130241e-24  0.1838976 0.434 0.309  1.865673e-19   IPAN1     Bmpr2
## 106  1.183126e-20  0.1330098 0.243 0.145  2.417599e-16   IPAN1      Ldlr
## 107  3.977896e-18  0.1003230 0.155 0.082  8.128433e-14   IPAN1     Lamp1
## 108  1.213296e-16  0.1025542 0.212 0.130  2.479249e-12   IPAN1      Lrp6
## 109  9.670794e-15  0.1142633 0.227 0.147  1.976130e-10   IPAN1  Tmem126a
## 110  0.000000e+00  1.2980715 0.990 0.654  0.000000e+00   IPAN2       Alk
## 111 5.540486e-287  1.0622072 0.430 0.071 1.132143e-282   IPAN2       Dcc
## 112 3.557226e-233  0.3622293 0.252 0.012 7.268835e-229   IPAN2     Nmur2
## 113 7.634807e-194  0.7217496 0.385 0.087 1.560096e-189   IPAN2       Ghr
## 114 1.085581e-153  0.3653681 0.309 0.052 2.218276e-149   IPAN2   Nectin3
## 115 8.583972e-115  0.4441081 0.516 0.239 1.754049e-110   IPAN2     Sorl1
## 116  6.777704e-68  0.2472605 0.251 0.076  1.384956e-63   IPAN2    Atp1a3
## 117  5.674870e-32  0.1841310 0.236 0.109  1.159603e-27   IPAN2     Traf3
## 118  1.518691e-15  0.1240995 0.227 0.135  3.103293e-11   IPAN2  Slc22a17
## 119  4.709349e-80  1.7925798 1.000 0.695  9.623083e-76   IPAN3      Gpc6
## 120  1.622181e-27  0.7533781 0.642 0.259  3.314765e-23   IPAN3     Oprm1
## 121  6.601298e-25  0.6926799 0.358 0.142  1.348909e-20   IPAN3     Epha7
## 122  9.049737e-23  0.3966274 0.217 0.016  1.849223e-18   IPAN3      Ror1
## 123  2.268212e-09  0.3030330 0.292 0.109  4.634865e-05   IPAN3     Ramp1
## 124  0.000000e+00  1.1795053 0.629 0.014  0.000000e+00   IPAN4    Bmpr1b
## 125 6.504642e-237  0.9028330 0.483 0.025 1.329159e-232   IPAN4     Flrt2
## 126 4.599746e-119  0.9167111 0.921 0.557 9.399121e-115   IPAN4     Unc5c
## 127 5.351041e-114  0.4655202 0.277 0.019 1.093432e-109   IPAN4     Ephb1
## 128  2.367353e-88  0.2369190 0.157 0.003  4.837450e-84   IPAN4     Npy5r
## 129  6.581974e-72  0.2937324 0.191 0.015  1.344960e-67   IPAN4     Cckar
## 130  1.043326e-67  0.2705104 0.181 0.014  2.131933e-63   IPAN4     Glp1r
## 131  1.590873e-63  0.3124106 0.230 0.036  3.250790e-59   IPAN4     Npy1r
## 132  1.283549e-21  0.2569076 0.318 0.151  2.622804e-17   IPAN4     Fgfr1
## 133  5.743617e-13  0.1744222 0.244 0.123  1.173651e-08   IPAN4   Slc16a7
## 134  2.051228e-11  0.1338159 0.196 0.093  4.191479e-07   IPAN4  Tnfrsf21

PBSvsINF

DotPlot(test1.seur, features = markers.new_ligand.pct_0.15.padj_0.001$gene, group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10.15))+ scale_y_discrete(limits=rev) + labs(title="ligand.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

DotPlot(test1.seur, features = markers.new_receptor.pct_0.15.padj_0.001$gene, group.by = "intAnno1",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10))+ scale_y_discrete(limits=rev) + labs(title="receptor.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

NatNeur2021

DotPlot(ref.seur, features = markers.new_ligand.pct_0.15.padj_0.001$gene, group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10.15))+ scale_y_discrete(limits=rev) + labs(title="ligand.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Warning in FetchData.Seurat(object = object, vars = features, cells = cells):
## The following requested variables were not found: Afdn
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.

DotPlot(ref.seur, features = markers.new_receptor.pct_0.15.padj_0.001$gene, group.by = "Anno2",
        cols = c("midnightblue","darkorange1")) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, vjust = 1,size = 10))+ scale_y_discrete(limits=rev) + labs(title="receptor.pct_0.15.padj_0.001") +
  scale_color_gradientn(colours  = material.heat(100))
## Warning in FetchData.Seurat(object = object, vars = features, cells = cells):
## The following requested variables were not found: Nectin3
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.